Game Development Reference
In-Depth Information
Now for the interesting part. In 4D, we can also express translation as
a matrix multiplication, something we were not able to do in 3D:
2
4 1 0 0 0
3
5
Using a 4 × 4 matrix to
perform translation in
3D
0 1 0 0
0 0 1 0
∆x ∆y ∆z 1
x y z 1
=
x+∆x y+∆y z+∆z 1
.
(6.11)
It is important to understand that this matrix multiplication is still a
linear transformation. Matrix multiplication cannot represent “translation”
in 4D, and the 4D zero vector will always be transformed back into the 4D
zero vector. The reason this trick works to transform points in 3D is that
we are actually shearing 4D space. (Compare Equation (6.11) with the
shear matrices from Section 5.5.) The 4D hyperplane that corresponds to
physical 3D space does not pass through the origin in 4D. Thus, when we
shear 4D space, we are able to translate in 3D.
Let's examine what happens when we perform a transformation with-
out translation followed by a transformation with only translation. Let R
be a rotation matrix. (In fact, R could possibly contain other 3D linear
transformations, but for now, let's assume R only contains rotation.) Let
T be a translation matrix of the form in Equation (6.11):
2
4 r 11 r 12 r 13
3
2
4 1 0 0 0
3
0
5
5
r 21 r 22 r 23
0
0 1 0 0
0 0 1 0
∆x ∆y ∆z 1
R =
,
T =
.
r 31 r 32 r 33
0
0
0
0
1
Then we could rotate and then translate a point v to compute a new point
v
by
= vRT .
v
Remember that the order of transformations is important, and since we have
chosen to use row vectors, the order of transformations coincides with the
order that the matrices are multiplied, from left to right. We are rotating
first and then translating.
Just as with 3 × 3 matrices, we can concatenate the two matrices into
a single transformation matrix, which we assign to the matrix M :
M = RT ,
v
= vRT = v ( RT ) = vM .
Search WWH ::




Custom Search