Function S2Cap.getCentroid

Returns the true centroid of the cap multiplied by its surface area (see s2centroids.h for details on centroids). The result lies on the ray from the origin through the cap's center, but it is not unit length. Note that if you just want the "surface centroid", i.e. the normalized result, then it is much simpler just to call center().

s2.util.math.vector.Vector!(double,3L) getCentroid() const;

The reason for multiplying the result by the cap area is to make it easier to compute the centroid of more complicated shapes. The centroid of a union of disjoint regions can be computed simply by adding their GetCentroid() results. Caveat: for caps that contain a single point (i.e., zero radius), this method always returns the origin (0, 0, 0). This is because shapes with no area don't affect the centroid of a union whose total area is positive.