Steiner's Theorem for Composite Bodies

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

In calculating the inertia tensor for composite bodies in 3D one can use Steiner's Theorem (also called the Parallel-Axis Theorem, https://en.wikipedia.org/wiki/Parallel_axis_theorem) to shift the local tensor to another point, specifically to each shape's respective local transform and additionally the center of mass for the entire body. This process is described by Dirk Gregorius http://www.bulletphysics.org/Bullet/php ... f=4&t=3702.

I understand the use of Steiner's Theorem in this algorithm, but I do not understand why the Steiner term is added when shifting to the shape's transform and subtracted when shifting to the center of mass of the entire body. Box2D performs a subtraction as well in b2Body::ResetMassData to center the inertia about the center of mass. Furthermore, I'm actually unsure as to how this operation is correct. I would figure that for each shape the tensor would need to be shifted from it's local position to the final center of mass for the entire body. Bullet seems to do just this in btCompoundShape::calculatePrincipalAxisTransform, and with an addition instead of a subtraction.

If someone could shed some light as to this derivation and edify me on the physics, that would be greatly appreciated!
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Steiner's Theorem for Composite Bodies

Post by RandyGaul »

Usually inertia tensors are calculated in model space (or local space) of the rigid body. Let's call the rigid body's reference frame A. Say we have a convex hull fixed in A. When A rotates the hull will rotate about A's origin, remaining fixed. When the inertia tensor of the hull is computed the tensor summation function used is probably Stan Melax's open source code (or just some version of his code). If so, his function will compute the inertia tensor of the hull with respect to the reference frame A, as if the hull were to be swung around A's origin.

Now say we have many hulls in A and would like to find an inertia tensor to represent all hulls in A together. We compute each hull's tensor and sum them together. The parallel axis theorem (PAT) only allows for the tensor to be shifted directly to the origin, or if at the origin already to another point. To shift from the origin to a point we do: I += PAT( offset_vector, mass ). To shift from a point to the origin we do: I -= PAT( offset_vector, mass ), which could also be thought of as I += PAT( -offset_vector, mass ). Shifting from one arbitrary point to another prerequisites a shift to the origin.

Since A's center of mass now likely does not reside at the origin, we must use the PAT to shift the tensor to A's origin (hence the subtraction). It is useful for A's tensor to be placed with respect to the origin such that transforming the tensor to world space takes up less computations -- this is just a way to precalculate the tensor for run-time.

Does that make sense? Hope that helps!

Edit: If a function calculates the tensor of a shape and assumes the shape sits in its own reference frame, then the tensor must be shifted from the origin of the shape space to local transform's center, hence I += PAT( vector, mass ). This is probably why Bullet is using an addition. It's just a difference between which space the tensor is calculated in originally.
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Re: Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

Awesome! Yes, that fully dispels my confusion. Thank you so much for the explanation, Randy!
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Steiner's Theorem for Composite Bodies

Post by Dirk Gregorius »

Regarding the addition/subtraction you were asking about:
- The inertia tensor is 'smallest' at the center of mass. So if you shift away from the center of mass you add (grow) and if you move into the center of mass you subtract (reduce).

Edit: Looking at the quoted post there was a sign error I just fixed.
Last edited by Dirk Gregorius on Wed May 04, 2016 6:13 pm, edited 1 time in total.
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Re: Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

Thanks for the elaboration, Dirk!
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Re: Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

I stumbled across a more mathematical explanation here, specifically equations 10 and 11.

Steiner's theorem states that:

I' = I_cm + mr^2

In Dirk's derivation while accumulating individual shape mass, we have I_cm and need to shift it by mr^2 to get I'. After we have accumulated all inertia, we have I' and need to find I_cm:

I_cm = I' - mr^2

I still don't know why Dirk uses the negative center of mass for the final shift, but I'm fairly sure this would result in the same Steiner term if using positive center of mass (just by looking at the algebra).
Last edited by JoeLubertazzi on Thu May 12, 2016 6:59 pm, edited 1 time in total.
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Steiner's Theorem for Composite Bodies

Post by Dirk Gregorius »

I think I fixed the negative center of mass in your cited post. This is what I was referring to in my earlier post.
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Re: Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

If I recall the T.mTranslation was originally negative and the mass.center was always negative, although I could be mistaken. In any case, thanks for all the help!
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Steiner's Theorem for Composite Bodies

Post by RandyGaul »

A 7 year old bug! :D
Dirk Gregorius
Posts: 861
Joined: Sun Jul 03, 2005 4:06 pm
Location: Kirkland, WA

Re: Steiner's Theorem for Composite Bodies

Post by Dirk Gregorius »

There is no bug. The sign of the translation doesn't matter (I leave this an exercise to prove). I agree that it is confusing though. What is important is that you add when you move away from the center of mass and subtract when you move into the center of mass.
RandyGaul
Posts: 43
Joined: Mon May 20, 2013 8:01 am
Location: Redmond, WA

Re: Steiner's Theorem for Composite Bodies

Post by RandyGaul »

Oh I see what you meant. I thought the old post was shifting to COM with a subtraction (I didn't read carefully).

I = I_cm + md^2, d^2 -> always positive, aka the distance from origin matters, and any vector (positive or negative) fixed on the origin will be the same result.
gilbo
Posts: 2
Joined: Fri May 29, 2015 5:27 pm

Re: Steiner's Theorem for Composite Bodies

Post by gilbo »

Hi Joe,

I can't comment on the code much, but as for the math, there are some simple principles from which you can derive nearly all of rotational/rigid-body mechanics, including the inertia tensor. (Apologies if these are obvious.)

principle 1) You can think of linear and angular velocity as jointly defining a vector field over 3d-space, which is the velocity at each point in space. (although of course only meaningful for points actually on the rigid body.) Specifically, let v be the linear velocity and w the angular velocity. Then the velocity of a point V(p) = v + (w x p). (x being the cross product)

1.1) The set of all velocity fields of the above form is closed under changes of origin/basis. proof sketch: Let Rp + r be a change of basis formula, where R is an orthonormal matrix. Then V(p) = (v + (w x r)) + (w x Rp). (w x y) = Wy, where W is an anti-symmetric matrix. The product WR of an anti-symmetric and orthonormal matrix is anti-symmetric, which means we can transform it back into a cross product. We usually choose to express angular velocity at the center of mass because it's convenient for many formulas, and for reasoning about the values, but we could express all our velocities in world coordinates...

principle 2) You can (more or less) derive all rotational mechanics by just looking at particle mechanics, the above notion of a velocity field, and cranking through the mathematical consequences. Many particular quantities fall out from this process.

2.1) Define the kinetic energy of a rigid body as the integration over the kinetic energy of all of its constituent particles. i.e. Integrate_p[ 0.5 * m(p) * <V(p),V(p> ] (where <x,y> denotes dot product of vectors). Now, consider the following algebraic manipulations:

(Let S_p be an abbreviation of Integrate_p)
(Let W be the anti symmetric matrix corresponding to the cross product (w x ...))
(Let P be the anti symmetric matrix corresponding to the cross product (p x ...))
(Let A’ x’ denote transposes of matrices and vectors)

= 0.5*S_p[ m(p) * <v,v> + 2*<v,(w x p)> + <(w x p),(w x p)> ]
= 0.5*S_p[ m(p)*<v,v> ] + S_p[ m(p)*<v,(w x p)> ] + 0.5*S_p[ m(p) * (see below) ]
= 0.5*S_p[ m(p) ]*<v,v> + <v, (w x S_p[ m(p) p ])> + 0.5*S_p[ m(p) * w’P’Pw ]
= 0.5* M *<v,v> + <v, (w x CoM)> + 0.5*w’ I w

for above: <(w x p),(w x p)> = <(p x w),(p x w)> = w’P’Pw

That is, we now have an expression, where none of the integrals depend any longer on the velocity field. So, we can pre-compute these three values

M = S_p[ m(p) ] is the total mass of the body.
CoM = S_p[ m(p) * p ] is the center-of-mass of the body
I = S_p[ m(p) * P’P ] is the “inertia tensor”

Note that the first of the three terms in the summation is the linear kinetic energy. If we use a coordinate frame centered at the center of mass, then the second term will always be zero. Finally, the last term is the angular kinetic energy, in which the inertia tensor plays the role of mass.

If we compose these two principles together, we can derive a formula for the inertia tensor expressed in a different coordinate frame. Forgive me for skipping that part. You can derive Steiner's theorem as a special case of such an exercise.
JoeLubertazzi
Posts: 9
Joined: Sun May 01, 2016 12:45 am

Re: Steiner's Theorem for Composite Bodies

Post by JoeLubertazzi »

Hey, gilbo!

First of all, thank you for the wonderful explanation; it was very clear and and gave me enough detail to expand the derivation about a different coordinate frame. If you have the opportunity, please let me know if my derivation is correct:

Given p' = Rp + r, where p is the original particle position, R is the rotation into the new coordinate frame, r is the translation into the new coordinate frame, and p' is the particle's position in the new coordinate frame, we can use the original derivation of kinetic energy with p' in place of p:

Integrate_p[ 0.5 * m(p) * <V(p'),V(p')> ]

= 0.5*S_p[ m(p) * [ <v,v> + 2 *<v,(w x p')> + <(w x p'),(w x p')> ] ]
= 0.5*S_p[ m(p) * [ <v,v> + 2 *<v,(w x (Rp + r))> + <(w x (Rp + r)),(w x (Rp + r))> ] ]
= 0.5*S_p[ m(p) * [ <v,v> + 2 *<v,((w x Rp) + (w x r))> + <((w x Rp) + (w x r)),((w x Rp) + (w x r))> ] ]
= 0.5*S_p[ m(p) * [ <v,v> + 2 *<v, (w x Rp)> + 2 * <v, (w x r)> + <(w x Rp), (w x Rp)> + <(w x r), (w x r)> + 2 * <(w x Rp), (w x r)> ] ]

Now using the scalar-triple product <a, (b x c)> = <b, (c x a)> = <c, (a x b)>, the definition of <(w x p),(w x p)> = w’P’Pw, and let Q be the anti-symmetric matrix of r:

= 0.5 * S_p[ m(p) * <v, v> + 2 * m(p) * <Rp, (v x w)> * + 2 * m(p) * <r, (v x w)> + m(p) * w'R'P'PRw + m(p) * w'Q'Qw + 2 * m(p) * <(w x Rp), (w x r)> ]
= 0.5 * S_p[ m(p) * <v, v> + 2 * m(p) * <(v x w), (r + Rp)> + m(p) * w'( R'P'PR +Q'Q )w + 2 * m(p) * <(w x Rp), (w x r)> ]
= 0.5 * M * <v, v> + M*<(v x w), (r + R*CoM)> + 0.5 * w'(R'IR + MQ'Q)w + <(w x (w x r)), R*CoM>

Here, the first term is the linear kinetic energy. The second term makes use of the center of mass in the new coordinate frame. The third term makes use of the inertia tensor in the new coordinate frame. I'm not entirely sure what the fourth term is (possibly related to gyroscopic motion?).

The R'IR makes sense, as this is how we transform the inertia tensor at CoM from body-space to world-space. The MQ'Q is the second term of Steiner's theorem (as described here). The r + R*CoM also makes sense, as this how how we transform the CoM from body-space to world-space.

Once again, if you can offer some feedback on my derivation that'd be greatly appreciated (I probably messed up some algebra along the way, too).

Thanks!
Post Reply