
14.2 Collision Impulses 345
* directions are set so that they are at right angles to it.
*/
void Contact::calculateContactBasis()
{
Vector3 contactTangent[2];
// Check whether the Z-axis is nearer to the X- or Y-axis
if (real_abs(contactNormal.x) > real_abs(contactNormal.y))
{
// Scaling factor to ensure the results are normalized.
const real s = (real)1.0f/
real_sqrt(contactNormal.z*contactNormal.z +
contactNormal.x*contactNormal.x);
// The new X-axis is at right angles to the world Y-axis.
contactTangent[0].x = contactNormal.z*s;
contactTangent[0].y = 0;
contactTangent[0].z = -contactNormal.x*s;
// The new Y-axis is at right angles to the new X- and Z-axes. ...