Game Development Reference
In-Depth Information
real_sqrt(contactNormal.z*contactNormal.z +
contactNormal.y*contactNormal.y);
// The new X axis is at right angles to the world X axis.
contactTangent[0].x = 0;
contactTangent[0].y = -contactNormal.z*s;
contactTangent[0].z = contactNormal.y*s;
// The new Y axis is at right angles to the new X and Z axes.
contactTangent[1].x = contactNormal.y*contactTangent[0].z -
contactNormal.z*contactTangent[0].y;
contactTangent[1].y = -contactNormal.x*contactTangent[0].z;
contactTangent[1].z = contactNormal.x*contactTangent[0].y;
}
// Make a matrix from the three vectors.
contactToWorld.setComponents(
contactNormal,
contactTangent[0],
contactTangent[1]);
}
where the setComponents method of the Matrix3 class sets the columns in the matrix.
It is implemented as
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 values from the given three vector components.
* These are arranged as the three columns of the vector.
*/
void setComponents(const Vector3 &compOne, const Vector3 &compTwo,
const Vector3 &compThree)
{
data[0] = compOne.x;
Search Nedrilad ::




Custom Search