Graphics Reference
In-Depth Information
camera. But instead of making the rotations relative to the fixed frame of
reference, the roll, pitch and yaw rotations are relative to the rotating frame
of reference. Another method is to use quaternions, which will be investigated
later in this chapter.
7.4.5 Rotating about an Axis
The above rotations were relative to the
x
-,
y
-and
z
-axes. Now let's consider
rotations about an axis parallel to one of these axes. To begin with, we will
rotate about an axis parallel with the
z
-axis, as shown in Figure 7.14. The
scenario is very reminiscent of the 2D case for rotating a point about an
arbitrary point, and the general transform is given by
⎡
⎤
⎡
⎤
x
y
z
1
x
y
z
1
⎣
⎦
⎣
⎦
=[
translate
(
p
x
,p
y
,
0)]
.
[
rotateβ
]
.
[
translate
(
−
p
x
,
−
p
y
,
0)]
.
(7.66)
and the matrix is
⎡
⎤
⎡
⎤
⎡
⎤
x
y
z
1
cos(
β
)
−
sin(
β
)0
p
x
(1
−
cos(
β
)) +
p
y
sin(
β
)
x
y
z
1
⎣
⎦
⎣
⎦
·
⎣
⎦
sin(
β
)
cos(
β
)0
p
y
(1
−
cos(
β
))
−
p
x
sin(
β
)
=
0
0
1
0
0
0
0
1
(7.67)
I hope you can see the similarity between rotating in 3D and 2D: the
x
-and
y
-coordinates are updated while the
z
-coordinate is held constant. We can
Y
P
′
(
x
′
, y
′
, z
′
)
p
x
b
z
= z
′
p
y
X
P
(
x, y, z
)
Z
Fig. 7.14.
Rotating a point about an axis parallel with the
z
-axis.