The centroid is the geometric mean of the vertices in a geometry. euclid supports centroid calculations for triangles, tetrahedrons and 2-4 points

centroid(x, y = NULL, z = NULL, t = NULL)

Arguments

x

A vector of triangles or tetrahedrons, or points if y, z, or t are provided

y, z, t

Vector of points

Value

a vector of points

Examples

p <- point(c(1, 5, 6), c(1, -2, 4)) # centroid of triangle t <- triangle(p[1], p[2], p[3]) centroid(t)
#> <2D points [1]> #> [1] <x:4, y:1>
plot(t, col = "grey", border = NA)
euclid_plot(centroid(t), pch = 16, cex = 2, col = "firebrick")
# Same as providing the points directly centroid(p[1], p[2], p[3])
#> <2D points [1]> #> [1] <x:4, y:1>