Game Development Reference
data = compTwo.x;
data = compThree.x;
data = compOne.y;
data = compTwo.y;
data = compThree.y;
data = compOne.z;
data = compTwo.z;
data = compThree.z;
The Inverse Transformation
It is worth recapping the result we saw in section 9.4.3 here—namely, that the inverse
of a rotation matrix is the same as its transpose. Why are we interested in the inverse?
Because, in addition to converting from contact coordinates to world coordinates, we
may have to go the other way as well.
To convert world coordinates into contact coordinates we use the inverse of the
basis matrix created in the previous code. Inverting a matrix in general, as we have
seen, is complex. Fortunately the basis matrix as we've defined it here represents a
rotation only: it is a 3
3 matrix, so it can't have a translational component; and
because both the contact axes and the world axes are orthonormal, there is no skewing
or scaling involved.
This means that we can perform the transformation from world coordinates into
contact coordinates by using the transpose of the basis matrix:
M basis =
This important result allows us to convert at will between contact coordinates and
Whenever some calculation is easier in one than another, we can simply convert
between them. We'll use this important result in the next section, and a great deal
more in the next chapter.
V ELOCITY C HANGE BY I MPULSE
Remember that the change in motion of both objects in a collision is caused by the
forces generated at the collision point by compression and deformation. Because we
are representing the whole collision event as a single moment in time, we use impulses
rather than forces. Impulses cause a change in velocity (both angular and linear, ac-
cording to D'Alembert's principle, just like forces).