The barycenter is the center of mass of 2 or more points. euclid supports calculating the barycenter of up to 4 weighted points. If the weights are the same between the points the barycenter corresponds to the centroid (or midpoint in the case of two points).

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

Arguments

x, y, z, t

vectors of weighted points. z and t are optional

Value

A point vector

See also

Examples

p <- weighted_point(
  x = c(4, 0, -3),
  y = c(2, -4, 7),
  w = c(20, 8, 13)
)
bc <- barycenter(p[1], p[2], p[3])
bc
#> <2D points [1]>
#> [1] <x:1, y:2.41>

plot(p, cex = as.numeric(parameter(p, "w") / 8))
euclid_plot(bc, pch = 16, col = "firebrick", cex = 3)