Game Development Reference
In-Depth Information
Excerpt from include/cyclone/core.h
/**
* Holds an inertia tensor, consisting of a 3x3 row-major matrix.
* This matrix is not padding to produce an aligned structure, since
* it is most commonly used with a mass (single real) and two
* damping coefficients to make the 12-element characteristics array
* of a rigid body.
*/
class Matrix3
// ... Other Matrix3 code as before ...
/**
* Sets the matrix to be a skew-symmetric matrix based on
* the given vector. The skew-symmetric matrix is the equivalent
* of the vector product. So if a,b are vectors, a x b = A_s b
* where A_s is the skew-symmetric form of a.
*/
void setSkewSymmetric(const Vector3 vector)
{
data[0] = data[4] = data[8] = 0;
data[1] = -vector.z;
data[2] = vector.y;
data[3] = vector.z;
data[5] = -vector.x;
data[6] = -vector.y;
data[7] = vector.x;
}
};
Now we can work the whole basis matrix through the same series of steps:
// Create the skew-symmetric form of the cross product.
Matrix3 impulseToTorque;
impulseToTorque.setSkewSymmetric(relativeContactPosition);
// This was a cross product.
Matrix3 torquePerUnitImpulse = impulseToTorque * contactToWorld;
// This was a vector transformed by the tensor matrix - now it's
// just plain matrix multiplication.
Matrix3 rotationPerUnitImpulse =
inverseInertiaTensor * torquePerUnitImpulse;
// This was the reverse cross product, so we'll need to multiply the
Search Nedrilad ::




Custom Search