The centroid is the geometric mean of the vertices in a geometry. euclid supports centroid calculations for triangles, tetrahedrons and 2-4 points
Arguments
- x
A vector of triangles or tetrahedrons, or points if
y,z, ortare provided- ...
arguments passed on to methods. Specifically the method for
euclid_geometryvectors accept up to three additional vectors ofeuclid_point(y,z, andtarguments) ifxis aeuclid_pointvector
See also
Other Locations:
barycenter(),
bisector(),
circumcenter(),
equidistant_line(),
point(),
radical(),
weighted_point()
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>