Centroid Calculator

Calculate the centroid (center of mass) for various 2D and 3D shapes. Supports 15+ shape types with visualization and export options.

Select 2D Shape Type
Rectangle
Triangle
Circle
Ellipse
Semicircle
Quarter Circle
Parabola
Circular Sector
Composite
Polygon
Rectangle Properties
Width (b):
units
Height (h):
units
Position X:
units
Position Y:
units
Select 3D Shape Type
Cube
Sphere
Cylinder
Cone
Pyramid
Composite 3D
Cube Properties
Side Length (a):
units
Position X:
units
Position Y:
units
Position Z:
units
Calculating...

What is a Centroid?

The centroid (also known as the geometric center or barycenter) is the arithmetic mean position of all the points in a shape. For objects with uniform density, the centroid coincides with the center of mass. It is a fundamental concept in mathematics, physics, and engineering.

For a polygon, the centroid is calculated using the shoelace integration formula. For continuous shapes like circles or ellipses, we use standard integral calculus. This tool applies these exact formulas to give you precise, reliable results.

General Polygon Centroid (Shoelace):

A = ½ ∑ (xᵢ yᵢ₊₁ – xᵢ₊₁ yᵢ)
Gₓ = (1/(6A)) ∑ (xᵢ + xᵢ₊₁)(xᵢ yᵢ₊₁ – xᵢ₊₁ yᵢ)
Gᵧ = (1/(6A)) ∑ (yᵢ + yᵢ₊₁)(xᵢ yᵢ₊₁ – xᵢ₊₁ yᵢ)

Historical Context & Mathematical Significance

The concept of the centroid dates back to Archimedes (c. 287–212 BC), who studied centers of gravity. The term "centroid" was coined in the 19th century, but the properties of triangle medians were known to Euclid. The centroid is one of the four classic triangle centers (along with the orthocenter, circumcenter, and incenter) and plays a key role in Euler's line.

In modern times, centroid calculations are vital in structural engineering (neutral axis of beams), computer graphics (mesh optimization), robotics (stability analysis), and GIS (polygon labeling).

How the Tool Works

  1. Select a shape from the dropdown. The input fields adjust automatically.
  2. Enter the required dimensions (e.g., width, height, radius, or vertices).
  3. Click “Calculate & Draw” – the tool computes the centroid using analytic geometry and renders the shape on the canvas.
  4. The centroid (G) is marked with a green dot. Results include exact coordinates and area.

Supported Shapes & Centroid Formulas

ShapeCentroid (relative to given origin)Key Parameters
Rectangle(x + w/2, y + h/2)Corner (x,y), width w, height h
Triangle((x₁+x₂+x₃)/3, (y₁+y₂+y₃)/3)3 vertices
Circle(cx, cy)Center (cx,cy), radius r
Ellipse(cx, cy)Center (cx,cy), semi-axes a, b
Semicircle(cx, cy + 4r/(3π))Base center (cx,cy), radius r, direction
Quarter Circle(cx + 4r/(3π), cy + 4r/(3π))Corner (cx,cy), radius r
Parabola(x₀ + 3b/4, y₀ + 3h/10)Base b, height h, origin (x₀,y₀)
Circular Sector(cx + R·sin(θ/2)·(2/(3θ/2)), cy + ... )Center, radius R, angle θ (rad)
PolygonIntegration (shoelace)List of vertices (≥3)
CompositeWeighted average of componentsCentroid & area of each sub-shape

Real‑World Applications

  • Structural Engineering: Determines the neutral axis of beams for bending stress analysis.
  • Robotics & Control: Used to compute the center of mass of robot links for balance and trajectory planning.
  • Computer Graphics: Essential for mesh simplification, collision detection, and procedural modeling.
  • Aerospace: Calculating the center of gravity of aircraft components.
  • Geography (GIS): Finding representative points for labeling regions and polygons.

Frequently Asked Questions

1. What is the difference between centroid and center of gravity?
For a uniform density shape, they are exactly the same. The centroid is a purely geometric property, while the center of gravity considers weight distribution. For constant density, both coincide.
2. Can I calculate the centroid of a concave polygon?
Yes. The shoelace formula used by this tool works for both convex and concave polygons, as long as the vertices are ordered sequentially (clockwise or counter-clockwise).
3. Why does the semicircle centroid move when I change the direction?
The centroid of a semicircle lies along its symmetry axis. Changing the direction (up/down) flips the sign of the Y-offset relative to the base center.
4. How accurate are the calculations?
All operations use double-precision floating-point arithmetic (IEEE 754), providing accuracy to ~15 decimal digits. This is sufficient for all practical engineering and research purposes.
5. What does "Composite" mean?
Composite allows you to combine two simpler shapes (e.g., a rectangle plus a circle). You provide the centroid and area of each part, and the tool calculates the overall centroid using the weighted average formula.

References & Further Reading: Wolfram MathWorld – Centroid · Wikipedia – Centroid · Coxeter, H.S.M. "Geometry Revisited" (1967) · Khan Academy – Geometry

Disclaimer: This tool is provided for educational and reference purposes. While we strive for 100% accuracy, we recommend cross-verifying critical engineering calculations with professional software.