Centroid Calculator
Calculate the centroid (geometric center) of a shape from its vertex coordinates.
Enter polygon vertices in clockwise or counterclockwise order.
About
The centroid of a polygon is the average position of all the points in its interior — the center of mass of a uniform-density lamina of the same shape. For a polygon with vertices (x_1, y_1), ..., (x_n, y_n) listed in order around the boundary, the centroid coordinates are given by Cx = (1 / 6A) × sum of (x_i + x_(i+1)) × (x_i × y_(i+1) − x_(i+1) × y_i), and Cy = (1 / 6A) × sum of (y_i + y_(i+1)) × (x_i × y_(i+1) − x_(i+1) × y_i), where A is the polygon area from the shoelace formula.
The centroid formulas are direct extensions of the shoelace formula. The shoelace formula computes a zeroth moment (the area); the centroid formulas compute first moments about each axis by multiplying each cross-product term by (x_i + x_(i+1)) for Cx and (y_i + y_(i+1)) for Cy, then dividing by 6A instead of 2A. The same algebraic structure that yields area also yields the centroid — a clean generalization that extends to second moments (moments of inertia) as well.
For a triangle, the centroid equals the simple average of the three vertex coordinates. This is the only polygon where the shortcut works — for polygons with more than three vertices, the centroid is the average of all interior points, which weights longer edges more heavily than shorter ones. The (x_i + x_(i+1)) and (y_i + y_(i+1)) multipliers in the formulas capture this weighting: each cross-product term (which corresponds to a triangle from the origin) is weighted by the average of its two endpoint coordinates, giving the centroid contribution of that sub-region.
Real-world applications are extensive. Structural engineers compute the centroid of a beam's cross section to find the neutral axis (where bending stress is zero) and the area moment of inertia about centroidal axes (which governs bending stiffness). Mechanical engineers use centroids for center-of-mass in rotor balancing, vibration analysis, and stability of machinery. GIS attaches a single representative point to each polygon (its centroid) for labeling and nearest-neighbor queries. Computer graphics uses the centroid as the natural origin for transformations like rotation and scaling.
This calculator accepts any number of vertices (minimum three, non-collinear) listed in clockwise or counterclockwise order. It computes the centroid, verifies it against a point-in-polygon test (so you can see when a concave polygon's centroid lies outside the shape), and shows the area, perimeter, orientation, and bounding box. The reference table lists centroids for common reference polygons so you can sanity-check your inputs against textbook values.
How to Use
- 1List the polygon vertices in orderEnter vertices in clockwise or counterclockwise order around the polygon. The first and last vertex are connected automatically by the formula wraparound.
- 2Add or remove vertices as neededUse the + and − buttons to add or remove rows. The calculator requires at least 3 non-collinear vertices for a valid polygon with non-zero area.
- 3Read the centroid and areaThe hero shows the centroid (Cx, Cy) computed from the first-moment formulas. The breakdown shows the area, the bounding box, and whether the centroid lies inside the polygon.
- 4Verify with a known caseA square with vertices (0,0), (1,0), (1,1), (0,1) should have centroid (0.5, 0.5) and area 1. A triangle with vertices (0,0), (6,0), (0,3) should have centroid (2, 1) and area 9.
- 5Watch for degenerate casesIf the area comes out zero, the vertices are collinear and the centroid is undefined. Add a fourth vertex off the line to get a real polygon.
Formula
Centroid Cx (x-coordinate):
Cx = (1 / 6A) × Σ (x_i + x_(i+1)) × (x_i y_(i+1) − x_(i+1) y_i)
Centroid Cy (y-coordinate):
Cy = (1 / 6A) × Σ (y_i + y_(i+1)) × (x_i y_(i+1) − x_(i+1) y_i)
Polygon area (shoelace):
A = ½ × |Σ (x_i y_(i+1) − x_(i+1) y_i)|
Notes:
- Indices wrap around: (x_(n+1), y_(n+1)) = (x_1, y_1).
- A must be non-zero; degenerate (collinear) polygons have no centroid.
- For a triangle, Cx = (x1 + x2 + x3) / 3 and Cy = (y1 + y2 + y3) / 3.
- The sign of the signed area cancels in the (1/6A) factor — absolute value of A is used.
Worked Example
Example 1 — Triangle (0,0), (6,0), (0,3):
- Area A = ½ × |0·0 − 6·0 + 6·3 − 0·0 + 0·0 − 0·3| = ½ × 18 = 9.
- Cx = (0+6)·0 + (6+0)·18 + (0+0)·0 / (6 × 9) = 108 / 54 = 2.
- Cy = (0+0)·0 + (0+3)·18 + (3+0)·0 / (6 × 9) = 54 / 54 = 1.
- Centroid = (2, 1) — also the simple average of the three vertices.
Example 2 — Square (0,0), (1,0), (1,1), (0,1):
- Area A = 1 (unit square).
- By symmetry, centroid = (0.5, 0.5) — the geometric center.
Example 3 — Rectangle (0,0), (6,0), (6,3), (0,3):
- Area A = 18. By symmetry, centroid = (3, 1.5).
- Verify: simple average of (0,0), (6,0), (6,3), (0,3) is (3, 1.5) — they agree here.
Tips
- For a triangle, the centroid equals the simple average of the three vertex coordinates — the only polygon where this shortcut works.
- For symmetric polygons (rectangle, regular polygon), the centroid is at the geometric center by symmetry — no need to compute first moments.
- For concave polygons, the centroid can lie outside the polygon interior — the calculator reports whether it is inside or outside.
- Point-in-polygon test (ray casting from the centroid) is the standard way to verify the centroid lies inside a concave polygon.
- For very large polygons (thousands of vertices), the centroid computation is O(n) — same as the shoelace area.
Common Mistakes
Common errors: (1) Listing vertices out of order, producing a self-intersecting polygon whose centroid formula gives a meaningless point. (2) Forgetting the factor 6A in the denominator (vs. 2A for area alone). (3) Assuming the centroid equals the vertex average for polygons with more than three vertices — it does not. (4) Using a degenerate (collinear) polygon, which has zero area and an undefined centroid.
Frequently Asked Questions
- What is the centroid of a polygon?
- The centroid (or geometric center) of a polygon is the point that is the average position of all the points in the polygon — the center of mass of a uniform-density lamina of the same shape. For a polygon with vertices (x1, y1), ..., (xn, yn) listed in order, the centroid coordinates are Cx = (1 / 6A) × sum of (x_i + x_(i+1))(x_i y_(i+1) - x_(i+1) y_i), and similarly for Cy with (y_i + y_(i+1)) in place of (x_i + x_(i+1)).
- How does the centroid formula relate to the shoelace formula?
- The shoelace formula gives the polygon area A = 0.5 × |sum of (x_i y_(i+1) - x_(i+1) y_i)|. The centroid formulas have the same cross products in their sum but multiply each by (x_i + x_(i+1)) for Cx and (y_i + y_(i+1)) for Cy, then divide by 6A instead of 2A. The two are siblings — the same algebraic structure generalizes from area to first moments.
- Is the centroid the same as the average of the vertices?
- Only for a triangle. For polygons with more than three vertices, the centroid is not the simple average of vertex coordinates — that would give the centroid of equal point masses at the vertices, not the centroid of the uniform lamina. The lamina centroid weights longer edges more heavily, which the (x_i + x_(i+1)) and (y_i + y_(i+1)) terms in the formula capture.
- Do the vertices need to be in order?
- Yes. The centroid formula assumes vertices are listed in order around the polygon boundary (clockwise or counterclockwise). Out-of-order vertices produce a self-intersecting 'polygon' whose signed area and first moments mix regions algebraically, giving a meaningless 'centroid.' Always trace the boundary in order.
- What happens if the polygon has zero area?
- If the polygon is degenerate (all vertices collinear or coincident), the area A is zero, the denominator 6A is zero, and the centroid is undefined. The calculator flags this case and shows an error. To get a meaningful centroid, you need at least three non-collinear vertices forming a real enclosed region.
- What are real-world uses of the centroid?
- Engineering uses the centroid as the center of mass for stress and stability analysis (uniform-density beams, plates, cross-sections). Computer graphics uses it as the center for transformations like rotation and scaling. GIS uses it to attach a single representative point to a polygon (for labeling or distance queries). Robotics uses it for balance and motion planning.
Centroid basics
The centroid of a polygon is the average position of all the points in its interior — the center of mass of a uniform- density lamina of the same shape. It is the unique point that, if the polygon were a physical plate of uniform material, would balance on the tip of a pin. For symmetric shapes (rectangle, regular polygon), the centroid coincides with the geometric center.
Center of mass
For a uniform-density lamina, the centroid equals the center of mass. Engineers use this for stress and stability analysis: a beam's neutral axis passes through its cross-section centroid; the buckling load depends on the area moment of inertia about centroidal axes. In physics, the center of mass motion of a rigid body obeys Newton's second law regardless of internal forces.
Shoelace extension
The centroid formulas extend the shoelace formula from area (a zeroth moment) to first moments about each axis. The same cross products (x_i y_(i+1) - x_(i+1) y_i) that give area also give the first moments when multiplied by (x_i + x_(i+1)) for Cx or (y_i + y_(i+1)) for Cy. Dividing by 6A gives the centroid coordinates — a clean generalization of the shoelace pattern.
Real-world (engineering)
Structural engineers compute the centroid of a beam's cross section to find the neutral axis (where bending stress is zero). Mechanical engineers use it for center of mass in rotor balancing and stability. GIS attaches a single representative point to each polygon for labeling and nearest- neighbor queries. Computer graphics uses the centroid as the natural origin for transformations.
| Polygon | Cx | Cy | Area | Inside? |
|---|---|---|---|---|
| Square (0,0),(1,0),(1,1),(0,1) | 0.500000 | 0.500000 | 1.000000 | Inside |
| Triangle (0,0),(6,0),(0,3) | 2.000000 | 1.000000 | 9.000000 | Inside |
| Rectangle (0,0),(6,0),(6,3),(0,3) | 3.000000 | 1.500000 | 18.000000 | Inside |
| Pentagon regular (r=1) | 0.000000 | 0.688191 | 2.377641 | Inside |
| Concave L-shape | 0.833333 | 0.833333 | 3.000000 | Inside |
The centroid formulas extend naturally to second moments (moments of inertia) by multiplying each cross-product term by additional quadratic factors of (x_i, y_i). These moments govern bending stiffness, rotational inertia, and structural stability — the same algebraic structure scales from area to first moment to second moment.
For concave polygons, the centroid can lie outside the polygon interior. The calculator runs a point-in-polygon (ray casting) test and reports whether the centroid is inside or outside — useful for design decisions where having the center of mass inside the shape matters.
Authoritative References
- Wikipedia — Centroid— wikipedia.orgComprehensive overview of the centroid, including formulas for polygons, integration-based centroids of continuous regions, and properties under transformation.
- Khan Academy — Triangle centroid— khanacademy.orgKhan Academy lessons on the centroid of a triangle (where the three medians meet) and its 2:1 division property.
- Wolfram MathWorld — Polygon Centroid— wolfram.comWolfram's encyclopedic entry covering the closed-form centroid formulas for simple polygons, with derivations and connections to first moments.
Try our other free calculators
CalcGenius has 1,200+ free, ad-free, browser-based calculators for finance, health, math, science, and everyday life. No sign-up required.