Game Development Reference
In-Depth Information
space and keep the object still) by transforming the object by the opposite
amount.
A lot of this chapter is filled with messy equations and details, so you
might be tempted to skip over it—but don't! There are a lot of important,
easily digested principles interlaced with the safely forgotten details. We
think it's important to be able to understand how various transform matri-
ces can be derived, so in principle you can derive them on your own from
scratch. Commit the high-level principles in this chapter to memory, and
don't get too bogged down in the details. This topic will not self-destruct
after you read it, so keep it on hand for reference when you need a particular
equation.
The second part of this chapter returns to general principles of trans-
formations. Section 5.6 shows how a sequence of primitive transformations
may be combined by using matrix multiplication to form a more compli-
cated transformation. Section 5.7 discusses various interesting categories
of transformations, including linear, a ne, invertible, angle-preserving, or-
thogonal, and rigid-body transforms.
5.1
Rotation
We have already seen general examples of rotation matrices. Now let's
develop a more rigorous definition. First, Section 5.1.1 examines 2D ro-
tation. Section 5.1.2 shows how to rotate about a cardinal axis. Finally,
Section 5.1.3 tackles the most general case of rotation about an arbitrary
axis in 3D.
5.1.1 Rotation in 2D
In 2D, there's really only one type of rotation that we can do: rotation about
a point. This chapter is concerned with linear transformations, which do
not contain translation, so we restrict our discussion even further to rotation
about the origin. A 2D rotation about the origin has only one parameter,
the angle θ, which defines the amount of rotation. The standard convention
found in most math topics is to consider counterclockwise rotation positive
and clockwise rotation negative. (However, different conventions are more
appropriate in different situations.) Figure 5.1 shows how the basis vectors
p and q are rotated about the origin, resulting in the new basis vectors p
and q
.
Now that we know the values of the basis vectors after rotation, we can
build our matrix:
p
cosθ sinθ
− sinθ cosθ
R (θ) =
=
.
2D rotation matrix
q
Search WWH ::




Custom Search