Game Development Reference
In-Depth Information
Figure 5.4
Rotating about the z -axis
in 3D
And finally, rotation about the z-axis (see Figure 5.4) is done with the
matrix
2
4 p
3
2
3
cosθ sinθ 0
− sinθ cosθ 0
0
5
4
5
3D matrix to rotate
about the z-axis
R z (θ) =
q
=
.
r
0
1
Please note that although the figures in this section use a left-handed
convention, the matrices work in either left- or right-handed coordinate
systems, due to the conventions used to define the direction of positive
rotation. You can verify this visually by looking at the figures in a mirror.
5.1.3 3D Rotation about an Arbitrary Axis
We can also rotate about an arbitrary axis in 3D, provided, of course, that
the axis passes through the origin, since we are not considering translation
at the moment. This is more complicated and less common than rotating
about a cardinal axis. As before, we define θ to be the amount of rotation
about the axis. The axis will be defined by a unit vector n .
Let's derive a matrix to rotate about n by the angle θ. In other words,
we wish to derive the matrix R ( n ,θ) such that when we multiply a vector
v by R ( n ,θ), the resulting vector v
is the result of rotating v about n by
the angle θ:
v
= v R ( n ,θ).
in terms
of v , n , and θ. The basic idea is to solve the problem in the plane perpen-
To derive the matrix R ( n ,θ), let's first see if we can express v
 
Search WWH ::




Custom Search