Centroid Calculator – Find Center of Mass for Polygon or Triangle
The centroid is a “balance point.” In coordinate geometry there are two common meanings:
-
Vertex-average centroid (mean of listed points): treats vertices as equal “masses.”
-
Filled-area centroid (lamina centroid): treats the polygon as a thin, uniformly filled plate.
For a triangle, both definitions give the same point. For a general polygon, they can differ.
1) Triangle centroid
For triangle vertices \(A(x_1,y_1)\), \(B(x_2,y_2)\), \(C(x_3,y_3)\), the centroid is the intersection of the three medians.
Its coordinates are the average of the vertex coordinates:
\[
\bar{x}=\frac{x_1+x_2+x_3}{3},\qquad
\bar{y}=\frac{y_1+y_2+y_3}{3}.
\]
2) Vertex-average centroid (mean of points)
If you list \(n\) vertices \((x_i,y_i)\) and want the average point of the vertices (not the filled shape), then:
\[
\bar{x}=\frac{1}{n}\sum_{i=1}^{n}x_i,\qquad
\bar{y}=\frac{1}{n}\sum_{i=1}^{n}y_i.
\]
This is fast and always defined, but it does not account for the polygon’s area distribution.
3) Filled polygon centroid (shoelace / area centroid)
For a simple (non-self-intersecting) polygon with vertices ordered around the boundary, define the
closed indexing convention \((x_{n+1},y_{n+1})=(x_1,y_1)\). First compute the signed area:
\[
A=\frac{1}{2}\sum_{i=1}^{n}\left(x_i y_{i+1}-x_{i+1}y_i\right).
\]
The sign of \(A\) indicates orientation:
• \(A>0\) typically means counterclockwise (CCW) ordering,
• \(A<0\) typically means clockwise (CW) ordering.
Then the centroid \((\bar{x},\bar{y})\) of the filled region is:
\[
\begin{aligned}
\bar{x} &= \frac{1}{6A}\sum_{i=1}^{n}(x_i+x_{i+1})\left(x_i y_{i+1}-x_{i+1}y_i\right),\\
\bar{y} &= \frac{1}{6A}\sum_{i=1}^{n}(y_i+y_{i+1})\left(x_i y_{i+1}-x_{i+1}y_i\right).
\end{aligned}
\]
These formulas use the same cross-term \(\left(x_i y_{i+1}-x_{i+1}y_i\right)\) as the shoelace area, which is why
the computation is efficient and stable for typical inputs.
4) Degenerate and self-intersecting cases
-
If \(A\approx 0\), the polygon is degenerate (collinear or nearly collinear points), so the area centroid is undefined.
A reasonable fallback is the vertex-average centroid.
-
If the polygon is self-intersecting (a “bow-tie” shape), the shoelace-based formulas correspond to a
signed-area interpretation (parts may cancel). For physical “filled” shapes, you usually want a simple polygon.
5) Practical input tips
- List vertices in order around the boundary (CW or CCW).
- Do not repeat the first vertex at the end; the calculator closes the polygon automatically for plotting and formulas.
- Units: if coordinates are in meters, the area is in \(\mathrm{m^2}\), and the centroid coordinates are in meters.