Composite Inertia Tensor

Please don't post Bullet support questions here, use the above forums instead.
devmelon
Posts: 19
Joined: Thu Nov 27, 2008 1:44 pm

Composite Inertia Tensor

Post by devmelon »

Hello world!

I am currently trying to understand angular momentum because I am trying to calculate mass properties manually for a project I am working on. I have calculated the center of mass and total mass without problems, but when I was going after the inertia tensor I felt alone in the dark. Now, I know there are formulas for calculating the inertia tensor for common shapes such as boxes and cylinders, and that is great because we compose our game objects with such primities. However, the problem is that I don't know what to do when I have a composite structure of shapes attached to a rigid body.

The basic scenario is that I have one rigid body with, say, 3 box shapes. I can calculate the inertia for each shape independently, but how can I calculate a "master" inertia for the whole rigid body? Is this even possible? The idea is that each shape would have a companion mass which would affect how the body as a whole would act when forces are applied. So, the first box might be a square of 2, have a mass of 3.4, be positioned in {0,0,0} in local transform. Then I'd calculate the inertia for that. Next, I'd calculate the other boxes with different dimensions, masses and positions. Finally I would simplify this whole description to a single center of mass, a single mass quantity, and a single inertia tensor, using a single rigid body.

I have stumbled around two days trying to understand what the inertia tensor is, and I have come to the conclusion that it is a transformation that you use to calculate the inertia for any given point in the shape. I don't know if I've understood the function of the inertia tensor correctly, in which case I would be deeply apprechiative of a simple explanation. I am not a huge mathematics fan so integrals and funny symbols just won't be much of a help. If it is possible to describe the problem without doing so, that would help a ton. I have looked at many pages, a couple of books, but the mathematics are sometimes lacking (both in book and in personal skill). It is interesting how vastly more complicated academic papers look from actual code that implements the function in many cases. I am hoping that this whole ordeal belongs to such a case.

Even some of the "helpful" images have me wondering whether the purpose of the illustration is to allow me to better understand the problem, or to help me make the choice to navigate to another website more quickly. :)

I know that constraints would achieve somewhat of what I am trying to achieve, but I've always fallen short with constraints in many different physics engines. The fixed constraints rarely are that fixed. I am looking for a rock solid composite structure. I can't see any other way to bind objects together, but if you have reasonable ideas then I am willing to try them out.
noctoz
Posts: 2
Joined: Thu May 21, 2009 11:14 am

Re: Composite Inertia Tensor

Post by noctoz »

http://emweb.unl.edu/NEGAHBAN/EM223/note18/note18.htm

Check out the section at the bottom in particular. Does this make sense to you?

Exemple 21.1 of this book also has some descriptive pictures.

http://books.google.se/books?id=tOFRjXB ... #PPA584,M1
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: Composite Inertia Tensor

Post by bone »

I think I can help a little bit. It is in fact possible to calculate the inertia tensor from two bodies that are joined together rigidly.

1) Obviously, mass = mass1 + mass2.

2) Now you need to find the composite CG, which equals ((CG1*mass1)+(CG2*mass2))/mass.

3) The inertia tensor is only slightly trickier. Much like the mass, it contains the sum of the two bodies' inertia tensors. But then you need to add in the two masses at their respective offsets from the new CG.

In other words, offset1 = CG1-CG, so you need to add in mass1 at offset1. You add it just like you would any point mass, using the normal inertia tensor sum:

tensor[j] += (mass1*((||offset1||^2*kron) - (offset1*offset1[j])))

where kron is the Kronecker delta, equals 1 if i==j, and 0 if i!=j
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Composite Inertia Tensor

Post by Dirk Gregorius »

Here is some pseudo code. Imagine you have shape with a relative transform to the rigid body and that it can return the inertia tensor in local coordinates.

Mat3 inertia = 0;

for ( all shapes s in body b )
{
Transform T = s->GetLocalTransform();
Mat3I = s->GetLocalInetia();

// Now rotate the local inertia tensor to align it with the body frame
I = T.mRotation * I * T.mRotation.Transose();

// Now we can apply the parallel axes theorem and move the rotated inertia into the body origin
I = I + Steiner( T.mTranslation );

// Finally accumulate at the origin
inertia += I;
}

// Assume that we also computed the center of mass in the same loop you now have to shift accumulated inertia into the center of mass
inertia = inertia - Steiner( mass_center );


Here is the code for the Steiner() function. It basically computes the Steiner part of the inertia and the passed vector points from the center of mass the translated origin. Basically you use: Ia = Ic + Is and Ic = Ia - Is where Ia is the inertia relative to some point a and Ic is the center of mass inertia. Is is the Steiner part which is defined like this:

http://de.wikipedia.org/wiki/Steinerscher_Satz


See the last matrix at the bottom of the page. Note that 'a' points away from the mass center.


You can find examples how to do this in 3D in Bullet's btCompoundShape::calculatePrincipalAxisTransform()and also in 2D Box2 in b2Body::ComputeMassFromShapes(). In 3D you need to account for the rotation and the Steiner is a matrix (tensor) now.

HTH,
-Dirk
Last edited by Dirk Gregorius on Thu May 12, 2016 8:08 pm, edited 3 times in total.
devmelon
Posts: 19
Joined: Thu Nov 27, 2008 1:44 pm

Re: Composite Inertia Tensor

Post by devmelon »

Thanks all! I am currently trying to implement this. All of you have been much helpful! I'll get back if I get any problems, or if I manage to solve it :D