Your question makes absolutely no sense at all.  See inline below.

On 14/03/14 08:03, al Vel wrote:
Hello R users,
I am trying to make a baricentric diagram like the ternary plot, but with 4
edges. I want to know how to calculate the centroid of the diamond.

Which centroid? A "diamond" (convex quadrilateral?) has 3 well defined centroids, in general all different.

The 4 edges are A, B, C, D.

Are A, B, C, and D the *lengths* of the edges? Or are they just labels for the edges?

If value of A=B=C=D, then the point should be at the
centre of the diamond. If A>B and B=C=D=0,

Since we are apparently talking about numerical values here it would seem that A, B, C, and D are the lengths of the sides. How can you have a "diamond" (convex quadrilateral?) with 3 sides of length 0 and the other non-zero?

Then the point should be at the corner of A.

What ***on earth*** does "the corner of A" mean?

For diamond, how to convert the value of A,B,C,D into cartesian
co-ordinates ?. if x1,x2,y1,y2 are A,B,C,D, then someone suggested:

   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])
   }
But this is not working. Please do suggest some help.

Try using Google. Wikipedia has a good article on quadrilaterals and outlines a procedure for finding the area centroid (I presume that's what you actually want) of a convex quadrilateral.

cheers,

Rolf Turner

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to