# Calculating real time moment of inertia around arbitrary axis in 3d

I have a 3d rigid body consisting of multiple triangles forming a closed mesh. I know how to calculate the moment of inertia around an arbitrary axis by splitting up the mesh into simpler shapes and using the parallel axis theorem and summarization to calculate the angular mass for the whole thing.

The problem is that in a real time simulation I would have to re-calculate the rotation mass for every impulse applied to the body. In my 2d simulation this is not a problem as there is just one orientation to any rotation axis, so I can calculate the angular mass just once.

Is there a way to pre-calculate the rotation mass for a 3d object, or is there a simplified way of doing this?

Why would you have to re-calculate it? The moment of inertia is a calculate-once feature of the object and persistent as long as you do not modify the object. Adding a force (or impulse) does not affect it's moment of inertia. Even if it rotates around "whatever" axis (of whatever reason), the object's moment of inertia is still always the same, there will just be additional forces in the equation.

Consider a car wheel that isn't attached at it's centerpoint P0 but at a point P1 at it's periphery. And never mind the inconvenient bumpyness when you drive :-). Spinning up that wheel from that silly attachpoint P1 requires a torque that consists of two parts:

1. Rotating a mass around P1, the mass is seen (from P1:s point of view) as a single m(ass) located at P0.
2. Spinning up the wheel. It wheel also rotates. Proof: Consider the attach point is just 1 mm off. It spins around the well placed wheel axis. Then consider it's 10 mm off - spins. The consider it's at the periphery - spins. No matter where P1 is, even if it's 1 km away, the wheel spins. So the 2nd thing to do is spinning up the wheel, and here the moment of inertia is what you work against.

From the wheels' point of view, it has no idea what it rotates around. Those mini-guys that live on the wheel only see their home rotating (eg. by using a compass) and of course there are some odd, inconvenient extra stuff, the centrifugal force around P1, but that has nothing to do with the wheel's moment of inertia.

A torque is always independent of attach point, or "view" point. The only thing that matters is the direction of the rotational axis. It doesn't matter (from the objects point of view) where the axis hits the object, that only introduces calculation for an external system, if the object is part of one such.

Another thing to know: If you lift up your car wheel and (try to) untighten a bolt, the wheel rotates (women do that :-)) and there is a torque "in the wheel". Even if you move the bolt 1 km from the wheel center, and rotate it, the torque will be the same. Or, if the move the wheel axis 1 km away - doesn't matter provided that both you and the wheel axis are free to move. If you are not, then you are an external system and the wheel becomes part of that.

If you only look at the object but nothing external, it's moment of inertia is persistent and thus a calc-once feature. Your pre-calc will do for the duration of the object un-modofied to it's shape or mass.

• Ok, the moment of inertia is not changing for a body unless it deformes, but the angular mass will be different around different axis. Take a pen for example. It is easy to rotate the pen around an axis going parallel to the pen through it's center of mass, however it is hard to rotate it around an axis perpendicular to that. Now when I apply an impulse to this pen, attempting to rotate it around the easy direction, the angular mass will be small, but when I try to rotate it around the hard direction, the angular mass will be bigger, so even if the impulse is applied to the center of mass, ... – Markus Fjellheim Sep 10 '17 at 17:33
• ... since the orientation of the rotation axis is different, the angular velocity the pen ends up having, differs. – Markus Fjellheim Sep 10 '17 at 17:35
• That is true, i actually did write: "The only thing that matters is the direction of the rotational axis." Usually one uses 3 numbers, x y z, as you know. And the good thing is that you do not need to do the tricky inertia re-calc during runtime :-). – Stormwind Sep 10 '17 at 18:24
• How would the inertia be stored? In 2d, it would just be a number, that is the angular mass around the axis going through the center of mass and perpendicular to the 2d plane. In 3d, I imagine you would need something more complicated? – Markus Fjellheim Sep 10 '17 at 18:47
• I imagine I would need a function like this: In comes an angular momentum and moment of inertia data, out goes the objects angular velocity (axis and magnitude)? – Markus Fjellheim Sep 10 '17 at 18:56