Game Development Reference

In-Depth Information

data[1] = compTwo.x;

data[2] = compThree.x;

data[3] = compOne.y;

data[4] = compTwo.y;

data[5] = compThree.y;

data[6] = compOne.z;

data[7] = compTwo.z;

data[8] = 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:

⎡

⎣

⎤

⎦

⎡

⎣

⎤

⎦

adg

beh

cf i

abc

def

ghi

M
basis
=

=

This important result allows us to convert at will between contact coordinates and

world coordinates.

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.

14.2.2

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).