Game Development Reference
In-Depth Information
Homogeneous coordinates and projection by division by w are interest-
ing, but why on earth would we want to use 4D space? There are two
primary reasons for using 4D vectors and 4 × 4 matrices. The first reason,
which we discuss in the next section, is actually nothing more than a no-
tational convenience. The second reason is that if we put the proper value
into w, the homogenous division will result in a perspective projection, as
we discuss in Section 6.5.
6.4.2 4 × 4 Translation Matrices
Recall from Section 4.2 that a 3 × 3 transformation matrix represents a
linear transformation, which does not contain translation. Due to the na-
ture of matrix multiplication, the zero vector is always transformed into
the zero vector, and therefore any transformation that can be represented
by a matrix multiplication cannot contain translation. This is unfortunate,
because matrix multiplication and inversion are very convenient tools for
composing complicated transformations out of simple ones and manipulat-
ing nested coordinate space relationships. It would be nice if we could find
a way to somehow extend the standard 3 × 3 transformation matrix to be
able to handle transformations with translation; 4 × 4 matrices provide a
mathematical “kludge” that allows us to do this.
Assume for the moment that w is always 1. Thus, the standard 3D
vector [x,y,z] will always be represented in 4D as [x,y,z,1]. Any 3 × 3
transformation matrix can by represented in 4D by using the conversion
2
4 m 11 m 12 m 13
3
5
2
4
3
5
0
m 11 m 12 m 13
m 21 m 22 m 23
m 31 m 32 m 33
m 21 m 22 m 23
0
Extending a 3 × 3
transform matrix into 4D
=⇒
.
m 31 m 32 m 33
0
0
0
0
1
When we multiply a 4D vector of the form [x,y,z,1] by a 4 × 4 matrix
of this form, we get the same result as the standard 3 × 3 case, the only
difference being the additional coordinate w = 1:
2
3
m 11 m 12 m 13
m 21 m 22 m 23
m 31 m 32 m 33
4
5
x y z
=
xm 11 +ym 21 +zm 31 xm 12 +ym 22 +zm 32 xm 13 +ym 23 +zm 33
;
2
4 m 11 m 12 m 13
3
5
0
m 21 m 22 m 23
0
x y z 1
m 31 m 32 m 33
0
0
0
0
1
=
xm 11 +ym 21 +zm 31 xm 12 +ym 22 +zm 32 xm 13 +ym 23 +zm 33
1
.
 
Search WWH ::




Custom Search