tri_area | R Documentation |
Input is x,y matrix in triplets, with 3 rows per triangle vertex.
tri_area(x)
x |
matrix of triangle coordinates |
numeric, area of triangles
pts <- structure(c(5L, 3L, 1L, 4L, 4L, 8L, 6L, 9L), .Dim = c(4L, 2L))
tri <- c(2, 1, 3, 2, 4, 1)
(a <- tri_area(pts[tri, ]))
plot(pts)
polygon(pts[head(as.vector(rbind(matrix(tri, nrow = 3), NA)), -1), ])
text(tapply(pts[tri,1], rep(1:2, each = 3), mean),
tapply(pts[tri,2], rep(1:2, each = 3), mean), labels = sprintf("area: %0.1f", a))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.