Computes the area-weighted centroid (center of mass) of the polygon. For a degenerate (zero-area) polygon this falls back to the average of the vertices.
the vector to store the centroid
polygon vertices as a flat array [x0, y0, x1, y1, ...]
[x0, y0, x1, y1, ...]
number of vertices to read from vertices
vertices
out
Computes the area-weighted centroid (center of mass) of the polygon. For a degenerate (zero-area) polygon this falls back to the average of the vertices.