Game Development Reference
In-Depth Information
In fact, in the acceleration equation
I 1 τ
the torque τ and the resulting angular acceleration θ are both given relative to the
world axes. So the inertia tensor we need should also be given in world coordinates.
We don't want to have to recalculate the inertia tensor by summing masses at
each frame, so we need a simpler way to get the inertia tensor in world coordinates.
We can achieve this by creating a new derived quantity: the inverse inertia tensor
in world coordinates. At each frame we can apply a change of basis transformation
to convert the constant inertia tensor in object coordinates into the corresponding
matrix in world coordinates.
As with the transform matrix we add an update to recalculate the derived quantity
at each frame. It gets put together in this way:
Excerpt from src/body.cpp
* Internal function to do an inertia tensor transform by a quaternion.
* Note that the implementation of this function was created by an
* automated code generator and optimizer.
static inline void _transformInertiaTensor(Matrix3 &iitWorld,
const Quaternion &q,
const Matrix3 &iitBody,
const Matrix4 &rotmat)
real t4 =[0]*[0]+[1]*[3]+[2]*[6];
real t9 =[0]*[1]+[1]*[4]+[2]*[7];
real t14 =[0]*[2]+[1]*[5]+[2]*[8];
real t28 =[4]*[0]+[5]*[3]+[6]*[6];
real t33 =[4]*[1]+[5]*[4]+[6]*[7];
real t38 =[4]*[2]+[5]*[5]+[6]*[8];
Search Nedrilad ::

Custom Search