Game Development Reference
In-Depth Information
Rather than use the contact normal in the first stage, we need to use all three
directions of the contact: the basis matrix. But if the contact normal is replaced by a
matrix, how do we perform the cross product?
The answer lies in an alternative formation of the cross product. Remember that
transforming a vector by a matrix gives a vector. The cross product of a vector also
gives a vector. It turns out that we can create a matrix form of the vector product.
For a vector
a
b
c
v
=
the vector product
v
×
x
is equivalent to the matrix-by-vector multiplication:
0
cb
x
c
0
a
ba 0
This matrix is called a “skew-symmetric” matrix, and an important result about cross
products is that the cross product is equivalent to multiplication by the corresponding
skew-symmetric matrix.
Because, as we have seen, v
×
=−
×
x
x
v ; and if we already have the skew-
symmetric version of v , we can calculate x
×
v without building the matrix form
of x . It is simply
0
cb
x
×
v
=−
c
0
a
x
ba 0
In fact we can think of the cross product in the first stage of our algorithm as
turning an impulse into a torque. We know from equation 10.1 that a force vector can
be turned into a torque vector by taking its cross product with the point of contact:
=
×
τ
p f
f
(which is just equation 10.1 again).
The skew-symmetric matrix can be thought of as this transformation, turning
force into torque.
It is useful to have the ability to set a matrix's components from a vector, so we
add a convenience function to the Matrix3 class: