Game Development Reference
In-Depth Information
Matrix3 inverseInertiaTensor;
};
Having the inverse at hand allows us to calculate the angular acceleration directly
from equation 10.3 without performing the inverse operation each time. When set-
ting up a rigid body, we can start with a regular inertia tensor, then call the inverse
function of the matrix, and set the rigid body's inverse inertia tensor to get the result:
Excerpt from src/body.cpp
void RigidBody::setInertiaTensor(const Matrix3 &inertiaTensor)
{
inverseInertiaTensor.setInverse(inertiaTensor);
_checkInverseInertiaTensor(inverseInertiaTensor);
}
10.2.3
T HE I NERTIA T ENSOR IN W ORLD C OORDINATES
There is still one subtle complication to address before we can leave the inertia ten-
sor. Throughout the discussion of moments of inertia I have deliberately not dis-
tinguished between the object's local coordinates and the game's world coordinates.
Consider the example in figure 10.2. In the first example the object's local axes are in
the same direction as the world's axes. If we apply a torque about the X axis, then we
will get the same moment of inertia whether we work in local or world coordinates.
In the second part of the figure, the object has rotated. Now whose X axis do we
need to use? In fact the torque is expressed in world coordinates, so the rotation will
depend on the moment of inertia of the object about the world's X axis. The inertia
tensor is defined in terms of the object's axis, however. It is constant: we don't change
the inertia tensor each time the object moves.
F IGURE 10.2
The moment of inertia is local to an object.