[R] centroid of diamond

Jim Lemon jim at bitwrit.com.au
Fri Mar 14 10:57:47 CET 2014


On 03/14/2014 08:19 PM, al Vel wrote:
> Hi,
> Exactly the matrix transformation is the one that pasted in my first
> mail. That is here:
>
> new_point <- function(x1, x2, y1, y2, grad=1.73206){
> b1 <- y1-(grad*x1)
> b2 <- y2-(-grad*x2)
> M <- matrix(c(grad, -grad, -1,-1), ncol=2)
> intercepts <- as.matrix(c(b1,b2))
> t_mat <- -solve(M) %*% intercepts
> data.frame(x=t_mat[1,1], y=t_mat[2,1])
> }
>
>
> The problem is: the points are going out of the rhombus.
>
Well, there must be something wrong with it then. I think that the 
matrix is:

pmat<-matrix(c(cos(pp),-2*sin(pp),0,sin(pp),2*cos(pp),0,0,0,1),
  nrow=3)

and as the upper angle of the rhombus is pi/3, I think pp should be:

pp<-pi/6

and the transformation is something like:

xymat<-matrix(c(0.5,0.3,0.5,0.3,1,1),nrow=3,byrow=TRUE)
pmat%*%xymat
           [,1]      [,2]
[1,] 0.6830127 0.4098076
[2,] 0.3660254 0.2196152
[3,] 1.0000000 1.0000000

Unfortunately, the hydrogeo package does not reveal the formula used for 
transforming the two ternary diagrams into the rhomboidal one. It does 
seem to work, however. I do recall trying to contact the maintainer when 
attempting to sort out the Piper diagram problem we had and getting no 
response.

Jim




More information about the R-help mailing list