Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

tri_area

Area of triangles


Description

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

Usage

tri_area(x)

Arguments

x

matrix of triangle coordinates

Value

numeric, area of triangles

Examples

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

Common Forms for Complex Hierarchical and Relational Data Structures

v0.7.0
GPL-3
Authors
Michael D. Sumner [aut, cre], John Corbett [ctb] (the original inspiration), Simon Wotherspoon [ctb], Kent Johnson [dtc], Mark Padgham [aut]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.