calculation of centroid

Centroid Calculator

Use this tool to calculate centroids for a triangle, a simple polygon, or weighted points (center of mass).

What is a centroid?

The centroid is the geometric “balance point” of a shape or a system of points. If your shape were made from a thin sheet of uniform material, the centroid would be the point where it can balance perfectly. In 2D geometry, the centroid is usually reported as a coordinate pair (x̄, ȳ).

You will see centroids in engineering statics, CAD workflows, machine design, robotics, computer graphics, and GIS. The exact formula depends on what you are averaging:

  • Triangle centroid: average of the three vertex coordinates.
  • Polygon centroid: area-weighted formula using the shoelace method.
  • Weighted points: mass-weighted average (center of mass).

Core centroid formulas

1) Triangle with vertices (x₁, y₁), (x₂, y₂), (x₃, y₃)

x̄ = (x₁ + x₂ + x₃) / 3
ȳ = (y₁ + y₂ + y₃) / 3

This is one of the simplest centroid calculations in geometry. The centroid always lies inside a non-degenerate triangle and is also the intersection of the medians.

2) Simple polygon centroid (area centroid)

For ordered vertices (xᵢ, yᵢ), i = 0 to n-1, let j = i+1 (wrapping to 0):

cross = xᵢyⱼ − xⱼyᵢ
A = (1/2) Σ(cross)

x̄ = [1 / (6A)] Σ((xᵢ + xⱼ) · cross)
ȳ = [1 / (6A)] Σ((yᵢ + yⱼ) · cross)

This method accounts for area, not just corner locations. If the polygon is self-intersecting or has zero area, the result is not physically meaningful as a standard centroid.

3) Weighted points (center of mass)

x̄ = Σ(wᵢxᵢ) / Σwᵢ
ȳ = Σ(wᵢyᵢ) / Σwᵢ

Use this when points represent discrete masses, loads, populations, or any weighted measurement. Heavier points pull the centroid more strongly.

Step-by-step intuition

Think of centroid calculation as a disciplined averaging process:

  • Uniform shape: every tiny area element contributes equally per unit area.
  • Point masses: each point contributes in proportion to its weight.
  • Result: one coordinate pair that represents the whole system’s spatial center.

In practice, the biggest source of error is not algebra—it is bad input ordering, inconsistent units, or missing points.

Common mistakes to avoid

  • Mixing units (for example, meters for x and millimeters for y).
  • Entering polygon vertices out of boundary order.
  • Using a self-intersecting polygon for a simple centroid formula.
  • For weighted points, allowing total weight to equal zero.
  • Assuming centroid and “visual center” are always identical for irregular shapes.

Where centroid calculations are used

Structural and mechanical engineering

Centroids are required for moments of inertia, beam calculations, bending stress analysis, and section properties. Composite section analysis starts with centroids.

Manufacturing and product design

In CAD/CAE pipelines, locating a part’s centroid helps with balancing, fixture planning, robotic gripping, and movement simulation.

Data science and clustering

In machine learning, a centroid often represents the mean location of a cluster in feature space (for example, k-means). Although mathematically similar, this is not an area centroid of a geometric polygon.

Quick checklist before you trust your answer

  • Did you use the correct centroid model (triangle, polygon, or weighted)?
  • Are all coordinates entered correctly and in consistent units?
  • For polygons, is the shape simple and non-self-intersecting?
  • Does the result look plausible relative to the geometry?

If you need a practical starting point, use the calculator above, load an example, and compare the computed centroid with your hand calculation. That combination builds both speed and confidence.

🔗 Related Calculators