Game Development Reference

In-Depth Information

Element[i].correctedPosition.x *

Element[i].correctedPosition.x);

Izz += Element[i].LocalInertia.z +

Element[i].mass * (Element[i].correctedPosition.x *

Element[i].correctedPosition.x +

Element[i].correctedPosition.y *

Element[i].correctedPosition.y);

Ixy += Element[i].mass * (Element[i].correctedPosition.x *

Element[i].correctedPosition.y);

Ixz += Element[i].mass * (Element[i].correctedPosition.x *

Element[i].correctedPosition.z);

Iyz += Element[i].mass * (Element[i].correctedPosition.y *

Element[i].correctedPosition.z);

}

// e11 stands for element on row 1 column 1, e12 for row 1 column 2, etc.

InertiaTensor.e11 = Ixx;

InertiaTensor.e12 = -Ixy;

InertiaTensor.e13 = -Ixz;

InertiaTensor.e21 = -Ixy;

InertiaTensor.e22 = Iyy;

InertiaTensor.e23 = -Iyz;

InertiaTensor.e31 = -Ixz;

InertiaTensor.e32 = -Iyz;

InertiaTensor.e33 = Izz;

Note that the inertia tensor is calculated about axes that pass through the combined

center of gravity for the rigid body, so be sure to use the corrected coordinates for each

element relative to the combined center of gravity when applying the transfer of axes

formulas.

We should also mention that this calculation is for the inertia tensor in body-fixed

coordinates, or local coordinates. As we discussed earlier in this chapter, it is better to

rewrite the angular equation of motion in terms of local coordinates and use the local

inertia tensor to save some number crunching in your real-time simulation.

Relativistic Time

To allow for a thorough understanding of how advanced space vehicles work as well as

give you a mechanism by which to alter time in your games, we would like to offer a

brief introduction to the theory of relativity, and particularly its effect on time. In our

everyday experience, it is safe to assume that the clock on your wall is ticking at the same

rate as the clock on our wall as we write this. However, the reason we all know the name