Advertisement

Inertia tensor and center of mass

Started by January 04, 2021 08:32 PM
0 comments, last by platypus19 4 years, 1 month ago

Hi!

I'm in the process of building a simple 3D physics engine and I'm currently reading through the code for the qu3e engine (https://github.com/RandyGaul/qu3e) since it's a simple implementation of a sequential impulse engine.

I'm trying to go through most of the code and understanding what's going on. There's a part I can't quite wrap my head around: calculating the inertia tensor for a rigid body which is an aggregate of multiple boxes. I understand the inertia tensor is calculated by calculating the tensor of each box and then adding it proportional to each box's mass. However, the calculation also takes the center of mass into account and I don't really understand what is happening.

Here's the code. At this point, the inertia variable contains the inertia tensor calculated as the sum of the individual boxes's inertia tensors. The mass variable is the sum of all the individual masses. The ‘lc’ variable is a vector to the local center of mass (relative to the body's transform, if I'm correct).

m_invMass = r32( 1.0 ) / mass;

lc *= m_invMass;

q3Mat3 identity;

q3Identity( identity );

inertia -= (identity * q3Dot( lc, lc ) - q3OuterProduct( lc, lc )) * mass;

m_invInertiaModel = q3Inverse( inertia );

Am I correct in that all the “inertia = …” line is doing is translating the tensor vector into the local center of mass (and of course scaling with the total mass)?

Would love to understand this and whether I'm missing something. If this is a standard operation, is there a reference I can read about somewhere? Thanks!

This topic is closed to new replies.

Advertisement