Function s2::point::planar_centroid[][src]

pub fn planar_centroid(a: &Point, b: &Point, c: &Point) -> Point

planar_centroid returns the centroid of the planar triangle ABC, which is not normalized. It can be normalized to unit length to obtain the "surface centroid" of the corresponding spherical triangle, i.e. the intersection of the three medians. However, note that for large spherical triangles the surface centroid may be nowhere near the intuitive "center" (see example in TrueCentroid comments).

Note that the surface centroid may be nowhere near the intuitive "center" of a spherical triangle. For example, consider the triangle with vertices A=(1,eps,0), B=(0,0,1), C=(-1,eps,0) (a quarter-sphere). The surface centroid of this triangle is at S=(0, 2eps, 1), which is within a distance of 2eps of the vertex B. Note that the median from A (the segment connecting A to the midpoint of BC) passes through S, since this is the shortest path connecting the two endpoints. On the other hand, the true centroid is at M=(0, 0.5, 0.5), which when projected onto the surface is a much more reasonable interpretation of the "center" of this triangle.