How this calculation works
Integrate mass, center of mass and planar inertia of a simple polygon with a nonnegative affine density field.
ρ=a+bx+cy; Mij=∫∫xⁱyʲdA; mass=aM00+bM10+cM01.A worked example
The default rectangle0≤x≤2,0≤y≤1 with density1+x has mass4, centroid(7/6,1/2) and centroidal polar inertia14/9.
Good to know
Simple planar polygon with3–150vertices; affine density a+b x+c y nonnegative at every vertex and positive total mass. Floating evaluation of analytic polynomial boundary integrals through cubic degree; no holes or arbitrary nonlinear density.
Reference: MIT OpenCourseWare: double integrals and mass (opens in a new tab) ↗
Density changes the geometric centroid
A uniform lamina has mass proportional to area, so its center of mass agrees with its geometric area centroid. An affine density can vary across the polygon, making one side heavier. This calculator integrates that variation rather than attaching equal mass to each entered vertex.
The density is a plus b times x plus c times y. Coefficients therefore depend on the coordinate unit and chosen origin. Translating the polygon while leaving those coefficients unchanged generally describes a different physical density field, even though the polygon's area remains unchanged.
Compare this with the Polyhedral solid volume centroid and inertia calculator from mesh. Integrate a nonuniform planar mass density to obtain mass, center of mass and moments; uniform 3D volume moments do not model an affine density field.
Defining the polygon and density
Enter one simple boundary in traversal order and three density coefficients. Either clockwise or counterclockwise traversal is accepted and normalized. The polygon must not cross itself, and holes are outside this page's domain. Vertices describe the boundary, not individual point masses.
The affine density must be nonnegative at every polygon vertex. An affine function attains its extrema over a triangle at vertices, and a simple polygon can be triangulated, so this condition also ensures nonnegativity throughout the filled region. Strictly positive total mass is still needed to define a center of mass.
The heavier-right rectangle example
The default rectangle has width two and height one, with density one plus x. Integrating across its width gives mass four. The x-weighted mass integral is fourteen-thirds, so dividing by four places the center at seven-sixths rather than the uniform rectangle's x coordinate of one.
The y coordinate remains one-half because density is independent of y. The centroidal moments are one-third about the horizontal axis and eleven-ninths about the vertical axis. Adding them gives a polar moment of fourteen-ninths, approximately 1.5555555556 in the corresponding mass-times-length-squared unit.
Analytic moments from boundary edges
Polynomial area moments are converted into line integrals using Green's theorem. For a raw moment x to power i times y to power j, one convenient boundary integrand is x to power i-plus-one times y to power j, divided by i-plus-one, integrated against dy.
Each polygon edge has coordinates affine in its segment parameter, so that integrand becomes an ordinary finite polynomial. Its coefficients can be integrated term by term. Because affine density raises the required degree by one, moments through cubic degree suffice for mass, first moments and second moments.
Inertia and the parallel-axis shift
The reported planar inertia matrix uses integrals of y squared and x squared on its diagonal, with minus the xy product moment off diagonal. This is the mechanical inertia convention, not simply the covariance matrix of coordinates. The two are related but their axis roles differ.
The origin matrix is shifted to the center of mass using the parallel-axis theorem. The trace of the centroidal matrix is the polar moment about the perpendicular axis through the centroid. Translation should preserve that centroidal polar moment when the density field is transformed consistently with the geometry.
Units and common interpretation mistakes
If density is mass per square meter and coordinates are meters, the mass is in that mass unit and inertia is mass times square meters. The gradient coefficients b and c then have one additional inverse-length factor compared with a. All three coefficients are not interchangeable dimensionless weights.
A negative off-diagonal inertia entry is not evidence of negative mass. Its sign reflects the xy product convention and chosen axes. By contrast, a negative physical density is rejected, and zero total density is rejected because dividing its first moments by zero would produce a meaningless centroid.
Checking an unfamiliar boundary
Start with constant density to compare the resulting center against a standard polygon centroid. Multiplying every density coefficient by the same positive factor should scale mass and inertia by that factor while leaving the center unchanged. These checks isolate density-unit errors from boundary-order problems.
For a measured plate, specify whether thickness has already been absorbed into the surface density. This page models a thin lamina; it does not integrate a three-dimensional solid or a varying out-of-plane thickness automatically. A nonlinear density field or a polygon containing holes needs a more general integration model.
A few questions, answered
Is this the average of vertex coordinates?
No. It integrates the filled polygon with its affine surface density; vertices are boundary locations, not equal point masses.
Why check density at vertices?
For an affine function, nonnegative vertex values ensure nonnegativity across the polygonal region.
What is the polar inertia?
It is the sum of the two centroidal in-plane axis moments, about the perpendicular centroidal axis.
Can I enter a polygon with holes?
No. This page accepts one simple boundary; holes require signed multi-ring integration not provided here.