How to calculate
Cross products of neighboring vertices give the signed area and the first moments. Divide those moments by the signed area to find the centroid coordinates.
Worked example
Use Vertices in boundary order, one x, y pair per line 0, 0 / 6, 0 / 0, 6. The result is (2, 2).
Input and result notes
Enter vertices in clockwise or counterclockwise boundary order. The polygon must enclose nonzero area and its edges cannot cross.