i
i
i
i
i
i
i
i
136 6. Transformation Matrices
the coordinates of the city geometry, expressing them as coordinates in the car’s
coordinate system. Both ways will lead to exactly the same matrix that is applied
to the geometry outside the car.
If the game also supports an overhead view to show where the car is in the
city, the buildings and streets need to be drawn in fixed positions while the car
needs to move from frame to frame. The same two interpretations apply: we
can think of the changing transformation as moving the car from its canonical
position to its current location in the world; or we can think of the transformation
as simply changing the coordinates of the car’s geometry, which is originally
expressed in terms of a coordinate system attached to the car, to express them
instead in a coordinatesystem fixed relative to the city. The change-of-coordinates
interpretation makes it clear that the matrices used in these two modes (city-to-car
coordinate change vs. car-to-city coordinate change) are inverses of one another.
The idea of changing coordinate systems is much like the idea of type conver-
sions in programming. Before we can add a floating-point number to an integer,
we need to convert the integer to floating point or the floating-point number to an
integer, depending on our needs, so that the types match. And before we can draw
the city and the car together, we need to convert the city to car coordinates or the
car to city coordinates, depending on our needs, so that the coordinates match.
When managing multiple coordinate systems, it’s easy to get confused and
wind up with objects in the wrong coordinates, causing them to show up in un-
expected places. But with systematic thinking about transformations between
coordinate systems, you can reliably get the transformations right.
Geometrically, a coordinate system, or coordinate frame, consists of an origin
and a basis—a set of three vectors. Orthonormal bases are so convenient that
In 2D, of course, there are
two basis vectors.
we’ll normally assume frames are orthonormal unless otherwise specified. In a
frame with origin p and basis {u, v, w}, the coordinates (u, v, w) describe the
point
p + uu + vv + ww.
When we store these vectors in the computer, they need to be represented in
terms of some coordinate system. To get things started, we have to designate
some canonical coordinate system, often called “global” or “world” coordinates,
which is used to describe all other systems. In the city example, we might adopt
the street grid and use the convention that the x-axis points along Main Street,
the y-axis points up, and the z-axis points along Central Avenue. Then when we
write the origin and basis of the car frame in terms of these coordinates it is clear
what we mean.
In 2D our convention is is to use the point o for the origin, and x and y for
In 2D, right handed means
y is counter-clockwise from
x.
the right-handed orthonormal basis vectors x and y (Figure 6.20).