See also: Why the inertia tensor is the inertia tensor.
History and Motivation
One day Atman Binstock and I wanted to write code to find the inertia tensor of a
body. References on this seemed difficult to come by, and what we
could find was hard to understand. Eventually, we developed a method
from scratch. I think the method is relatively simple, or at least is different from
most of what's out there. In
pursuing this method and writing it up, my main goal has been to seek intuition,
a clear and deep feeling for what's going on behind the math. The
available references seemed very opaque.
The basic idea is that you can iterate over a set of tetrahedra, one tetrahedron for each triangle in your mesh. By computing the inertia for each tetrahedron, then adding them up, you get your answer.
Originally I thought this was a super cool new idea, but that turns out not
to be so. At least one other paper has pointed this out before, and has
shown the idea to be more broadly applicable (to things like Fourier
transforms). See the Zhang/Chen paper in the References below.
Notes
You may notice that I insist on computing the covariance (2nd mass moment) of
the body, then convert that to an inertia tensor. This is different from
the way most references will do it -- they will compute the inertia tensor
directly.
My belief is that the covariance matrix is the natural form of the data, yielding the most symmetry and granting the most thorough understanding of the problem. The inertia tensor, in my view, is a less important concept; it's just the covariance matrix diddled around so that you can more directly ask the question "what happens when I push in a certain direction?" For a more involved explanation and the underlying math, see Why the inertia tensor is the inertia tensor.
Sample Source Code will be available at some point, but not now!
Acknowledgements
Thanks to Atman Binstock for working through the ideas with me, fixing my calculus errors, and making the first running version. And hopefully for contributing the bulk of the example code that I hope to have here.
Other References
The following paper predates this one and talks about the more general applicability of tetrahedral summation:
"Efficient
Texture Extraction for 2D/3D Objects in Mesh Representation",
Cha Zhang and Tsuhan Chen
Stan Melax recently wrote up some sample source code along with some comments describing why it does what it does [link forthcoming].
I'm told this book is good... http://www.wkap.nl/prod/b/0-7923-9145-4