tri_area: Area of triangles

Description Usage Arguments Value Examples

View source: R/triangles.R

Description

Input is x,y matrix in triplets, with 3 rows per triangle vertex.

Usage

1

Arguments

x

matrix of triangle coordinates

Value

numeric, area of triangles

Examples

1
2
3
4
5
6
7
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))

silicate documentation built on Nov. 13, 2020, 5:08 p.m.