Finding the Inertia Tensor of a 3D Solid Body,
Simply and Quickly

Part 3: The Inertia of a Solid Body

[back to main article]
 

Our overall plan for computing the inertia of a solid body is as follows:

0) Pick an arbitrary reference point.
1) Iterate over each triangle in the surface of the solid, forming a tetrahedron between that triangle and the reference point.
2) Compute the covariance, mass, and center-of-mass for each tetrahedron.
3) Combine these per-tetrahedron properties to yield a result for the whole body.

We'll run through these steps in order.

 

0) Picking an arbitrary reference point.

The coordinates of the point don't matter, except insofar as implementation details involving numerical accuracy.  one good choice might be the origin, since your mesh is probably stored with coordinates near the origin.  Another option might be to pick an arbitrary vertex from the mesh, or to iterate over all the vertices and average them.

1) Form tetrahedra.

Each triangle, along with that reference point, defines a tetrahedron.  Some of them will be positive-volume tetrahedra, some will be negative-volume.  The negative tetrahedra cancel out excess positive tetrahedra, to yield only the mass that is inside your mesh.  (An explanation of why this is so is coming up in the revised treatment of this algorithm).

Your input might be a set of volumes that interpenetrate each other.  A naive processing of this input would cause the mass in overlapping areas to be counted multiple times, which may not be what you want.  To fix this, you could clip the volumes against each other.
 

2) Computing the properties for each tetrahedron.

Each tetrahedron or compound body in the system is represented by 3 quantities: the covariance matrix C, the center-of-gravity x, and the mass m.  We call such a body B, and say B = { C, x, m }. 

Computing the mass m is straightforward; multiply the tetrahedron's density by its volume.  The volume of the tetrahedron is 1/6 the determinant of the matrix A, in other words, 1/6 the triple-product of the edge vectors v1 - v0, v2 - v0, and v3 - v0.  We showed how to compute C and x in Part 2, by applying the transform A to the known equation for the canonical tetrahedron.


3) Combining these properties to yield a result for the whole body.

Let B1 = { C1, x1, m1 } and B2 = { C2, x2, m2 }.  We want to find B3= Combine(B1, B2) = { C3, x3, m3 }.  Given the definition of Combine, we can accumulate the tetrahedron properties one by one until we have the result for the whole body.

Mass is easy: m3 = m1 + m2.  Center-of-mass is not much more involved: x3 = (x1m1 + x2m2) / (m1 + m2).  It's the average of the old centers, weighted by mass.  This is a common-enough computation that we won't go into it here, but you can derive it by treating the two bodies as clouds of point masses.

Now that we have the new center-of-mass, we can compute the new covariance C3.  To do this, we translate C1 and C2 so that their origins are at x3, then add them.  In other words: C1' = Translate(C1, x3 - x1); C2' = Translate(C2, x3 - x2); C3= C1' + C2'.

And of course, the inertia tensor I3 = 13tr C3 - C3.

 

That's all.  I'm tired and this article is done!