Graphics Programs Reference
In-Depth Information
1.2.1 Homogeneous Coordinates
Unfortunately, our simple 2
2 transformation matrix cannot generate all the basic
transformations that are needed in practice! In particular, it cannot generate transla-
tion . This is easy to see by arguing that any object containing the origin will, after any
of the transformations above, still contain the origin [i.e., the result of (0 , 0) T is (0 , 0)
for any matrix T ].
Translations can be expressed by x = x + m , y = y + n , and one way to implement
them is to generalize our transformations to P = PT +( m, n ), where T is the familiar
2
×
2 transformation matrix. A more elegant approach, however, is to stay with the
compact notation P = PT and to extend T to the 3
×
×
3matrix
ab 0
cd 0
mn 1
.
T =
(1.7)
This approach is called homogeneous coordinates and is commonly used in projective
geometry. It makes it possible to unify all the two-dimensional transformations within
one 3
3 matrix with six parameters. The problem is that a two-dimensional point (a
pair) cannot be multiplied by a 3
×
3 matrix. This is solved by representing our points
in homogeneous coordinates, which is done by extending the point ( x, y ) to the triplet
( x, y, 1). The rules for using homogeneous coordinates are the following:
1. To transform a point ( x, y ) to homogeneous coordinates, simply add a third
component of 1. Hence, ( x, y )
×
( x, y, 1).
2. To transform the triplet ( a, b, c ) from homogeneous coordinates back into a pair
( x, y ), divide by the third component. Hence, ( a, b, c )
( a/c, b/c ).
This means that a point ( x, y ) has an infinite number of representations in homo-
geneous coordinates. Any triplet ( ax, ay, a )where a is nonzero is a valid representation
of the point. This suggests a way to intuitively understand homogeneous coordinates.
We can consider the triplet ( ax, ay, a ) a point in three-dimensional space.
When a
varies from 0 to
, the point travels along a straight ray from the origin to infinity.
The direction of the ray is determined by x and y but not by a . Therefore, each two-
dimensional point ( x, y ) corresponds to a ray in three-dimensional space. To find the
“real” location of the point, we look at the z = 1 plane. All points on this plane have
coordinates ( x, y, 1), so we only have to strip off the “1” in order to see where the
point is located. Section 1.4 shows that homogeneous coordinates can also be applied
to three-dimensional points.
Exercise 1.11: Write the transformation matrix that performs (1) a y -reflection, (2)
a translation by
1inthe x and y directions, and (3) a 180 counterclockwise rotation
about the origin. Apply this compound transformation to the four corners (1 , 1), (1 ,
1),
(
1 , 1), and (
1 ,
1) of a square centered on the origin. What are the transformed
corners?
Matrix (1.7) is the general transformation matrix in two dimensions. It produces
the most general linear transformation, x
= ax + cy + m , y
= bx + dy + n ,andit
shows that this transformation depends on just six numbers.
Search WWH ::




Custom Search