i
i
i
i
i
i
i
i
6.3. Translation and Affine Transformations 131
but this scheme also makes it obvious how to compose two affine transformations:
simply multiply the matrices.
A problem with this new formalism arises when we need to transform vec-
tors that are not supposed to be positions—they represent directions, or offsets
between positions. Vectors that represent directions or offsets should not change
when we translate an object. Fortunately, we can arrange for this by setting the
third coordinate to zero:
⎡
⎣
10x
t
01y
t
00 1
⎤
⎦
⎡
⎣
x
y
0
⎤
⎦
=
⎡
⎣
x
y
0
⎤
⎦
.
If there is a scaling/rotation transformation in the upper-left 2 × 2 entries of the
matrix, it will apply to the vector, but the translation still multiplies with the zero
and is ignored. Furthermore, the zero is copied into the transformed vector, so
direction vectors remain direction vectors after they are transformed.
This is exactly the behavior we want for vectors, so they fit smoothly into the
system: the extra (third) coordinate will be either 1 or 0 depending on whether we
are encoding a position or a direction. We actually do need to store the homoge-
This gives an explanation
for the name “homoge-
neous:” translation, rota-
tion, and scaling of posi-
tions and directions all fit
into a single system.
neous coordinate so we can distinguish between locations and other vectors. For
example,
⎡
⎣
3
2
1
⎤
⎦
is a location and
⎡
⎣
3
2
0
⎤
⎦
is a displacement or direction.
Later, when we do perspective viewing, we will see that it is useful to allow the
homogeneous coordinate to take on values other than one or zero.
Homogeneous coordinates are used nearly universally to represent transfor-
mations in graphics systems. In particular, homogeneous coordinates underlie the
Homogeneous coordinates
are also ubiquitous in com-
puter vision.
design and operation of renderers implemented in graphics hardware. We will see
in Chapter 7 that homogeneous coordinates also make it easy to draw scenes in
perspective, another reason for their popularity.
Homogeneous coordinates can be considered just a clever way to handle the
bookkeeping for translation, but there is also a different, geometric interpretation.
The key observation is that when we do a 3D shear based on the z-coordinate we
get this transform:
⎡
⎣
10x
t
01y
t
00 1
⎤
⎦
⎡
⎣
x
y
z
⎤
⎦
=
⎡
⎣
x + x
t
z
y + y
t
z
z
⎤
⎦
.
Note that this almost has the form we want in x and y for a 2D translation, but
has a z hanging around that doesn’t have a meaning in 2D. Now comes the key