You are on page 1of 9

Chapter 9

Rotation About an
Arbitrary Axis
9.1

Quick Review

Given a point P = (x; y; z; 1) in homogeneous coordinates, let P 0 = (x0 ; y 0 ; z 0 ; 1)


be the corresponding point after a rotation around one of the coordinate axis has
been applied. You will recall the following from our studies of transformations:
1. Rotation about the x-axis by an angle x , counterclockwise (looking along
the x-axis towards the origin). Then P 0 = Rx P where the rotation matrix,
Rx ,is given by:
3
2
1
0
0
0
6 0 cos x
sin x 0 7
7
Rx = 6
4 0 sin x
cos x 0 5
0
0
0
1

2. Rotation about the y-axis by an angle y , counterclockwise (looking along


the y-axis towards the origin). Then P 0 = Ry P where the rotation matrix,
Ry ,is given by:
2
3
cos y 0 sin y 0
6
0
1
0
0 7
7
Ry = 6
4 sin y 0 cos y 0 5
0
0
0
1

3. Rotation about the z-axis by an angle z , counterclockwise (looking along


the z-axis towards the origin). Then P 0 = Rz P where the rotation matrix,
Rz ,is given by:
2
3
cos z
sin z 0 0
6 sin z
cos z 0 0 7
7
Rz = 6
4 0
0
1 0 5
0
0
0 1
117

118

CHAPTER 9. ROTATION ABOUT AN ARBITRARY AXIS


Note that the above transformations also apply to vectors.
You will also recall that
Rx 1

= RxT

Ry 1

= RyT

Rz 1

= RzT

This means in particular that these matrices are orthogonal. It can also be
proven that the product of two orthogonal matrices is itself an orthogonal matrix
(see problems at the end of the chapter). So, if we combine several rotations
about the coordinate axis, the matrix of the resulting transformation is itself an
orthogonal matrix.
One way of implementing a rotation about an arbitrary axis through the
origin is to combine rotations about the z, y, and x axes. The matrix of the
resulting transformation, Rxyz , is
2
3
Cy Cz
Cy Sz
Sy
Sx Sy Sz + Cx Cz
Sx Cy 5 (9.1)
Rxyz = Rx Ry Rz = 4 Sx Sy Cz + Cx Sz
Cx Sy Cz + Sx Sz Cx Sy Sz + Sx Cz
Cx Cy

where

Ci = cos

and Si = sin

for i = x; y; z

From what we noticed above, Rxyz is an orthogonal matrix. This means that
its inverse is its transpose.

9.2

Rotation About an Arbitrary Axis Through


the Origin

Goal: Rotate a vector v = (x; y; z) about a general axis with direction vector rb
(assume rb is a unit vector, if not, normalize it) by an angle (see gure 9.1).
Because it is clear we are talking about vectors, and vectors only, we will omit
the arrow used with vector notation.
We begin by decomposing v into two components: one parallel to rb and one
perpendicular to rb. Let us denote vk the component parallel to rb and v? the
component perpendicular to rb. You will recall from our study of vectors that
vk

Similarly,

= comprbv
v rb
b
=
2r
kb
rk
= (v rb) rb since rb is a unit vector
v?

=
=

orthrbv

v (v rb) rb

9.2. ROTATION ABOUT AN ARBITRARY AXIS THROUGH THE ORIGIN119


And we have
v = v k + v?

Figure 9.1: Rotation about a general axis through the origin, showing the axis
of rotation and the plane of rotation (see [VB1])
Let T denote the rotation we are studying. We need to compute T (v).
T (v)

= T vk + v?
= T vk + T (v? )

since T is a linear transformation. Also,


T vk = vk

120

CHAPTER 9. ROTATION ABOUT AN ARBITRARY AXIS

Figure 9.2: Rotation about a general axis through the origin, showing vectors
on the plane of rotation (see [VB1])

9.2. ROTATION ABOUT AN ARBITRARY AXIS THROUGH THE ORIGIN121


since vk has the same direction as rb and we are rotating around an axis with
direction vector rb(see gure 9.1). Therefore,
T (v) = vk + T (v? )

So, T (v? ) is the only quantity we need to compute. For this, we create a two
dimensional basis in the plane of rotation (see gure 9.1 and 9.2). We will use
v? as our rst basis vector. For our second, we can use
w

=
=

Looking at gure 9.2, we see that


T (v? )

rb
rb

(9.2)

v?
v

cos v? + sin w

cos v? + sin (b
r

v)

and therefore
T (v)

= vk + T (v? )

(v rb) rb + cos v? + sin (b


r

(1

v)

(v rb) rb + cos [v (v rb) rb] + sin (b


r

v)

(v rb) rb + cos v cos (v rb) rb + sin (b


r
cos ) (v rb) rb + cos v + sin (b
r

v)

v)

We would like to express this as a matrix transformation, in other words, we


want to nd the matrix R such that T (v) = Rv. For this, we rst establish
some intermediary results.
Lemma 97 If u = (ux ; uy ; uz ) and v = (vx ; vy ; vz ) then
2
3
0
uz uy
0
ux 5 v
u v = 4 uz
uy ux
0
Proof.

=
2

i
ux
vx

j
uy
vy

uy v z
= 4 u z vx
ux vy
2
0
= 4 uz
uy

k
uz
vz

3
uz vy
u x vz 5
uy v x

uz
0
ux

3
uy
ux 5 v
0

122

CHAPTER 9. ROTATION ABOUT AN ARBITRARY AXIS

Lemma 98 Using the notation of the previous lemma, we have


2
3
u2x
ux uy ux uz
u2y
uy uz 5 v
(u v) u = 4 ux uy
ux uz uy uz
u2z

Proof.

u v = ux vx + uy vy + uz vz
So,
(u v) u

(ux vx + uy vy + uz vz ) u
2

3
ux
= (ux vx + uy vy + uz vz ) 4 uy 5
uz
3
2
2
ux uy ux uz
ux
uy uz 5 v
u2y
= 4 ux uy
ux uz uy uz
u2z

We are now ready to write T (v) as a matrix transformation.


T (v)

where

cos ) (v rb) rb + cos v + sin (b


r v)
3
2
2
2
ux uy ux uz
ux
1
uy uz 5 v + 4 0
u2y
= (1 cos ) 4 ux uy
0
ux uz uy uz
u2z
8
3 2
2
2
ux uy ux uz
ux
1
<
uy uz 5 + 4 0
u2y
=
(1 cos ) 4 ux uy
:
0
ux uz uy uz
u2z
2
2
tux uy Suz tux uz + Suy
tux + C
tuy uz Sux
tu2y + C
= 4 tux uy + Suz
tux uz Suy tuy uz + Sux
tu2z + C
=

(1

rb =
=

cos

sin

t =

3
0
0 5 cos v+ sin
1
3
0 0
1 0 5 cos + sin
0 1
3
0
1
0

5v

3
0
uz uy
4 uz
0
ux 5 v
uy ux
0
2
39
0
uz uy
=
4 uz
0
ux 5 v
;
uy ux
0

(ux ; uy ; uz )

cos

9.3

Assignment

1. Prove that the product of two orthogonal matrices is also an orthogonal


matrix.

9.3. ASSIGNMENT

123

2. Prove equation 9.1


3. Prove equation 9.2
4. How would you implement rotation about an axis not going through the
origin? First, consider the cases in which the axis of rotation is parallel to
one of the coordinate axes. Then, consider the general case. In each case,
derive the corresponding transformation matrix.

Bibliography
[BF1] Burden, Richard L., and Faires, Douglas J., Numerical Analysis,Brooks/Cole, sixth edition, 1997.
[BG1] Burger, Peter, and Gillies, Duncan, Interactive Computer Graphics,
Addison-Wesley, 1990.
[DD1] Deitel, H.M., and Deitel, P. J., Java, How to Program, Prentice Hall,
1999.
[DP1] Dunn, Fletcher and Parberry, Ian, 3D Math Primer for Graphics and
Game Development, Wordware Publishing, Inc., 2002.
[FD1] Foley, J.D., Van Dam, A., Feiner, S.K., and Hughes, J.F., Computer
Graphics, Principles and Practices, Addison-Wesley, 1995.
[FD2] Foley, J.D., Van Dam, A., Feiner, S.K., Hughes, J.F., and Philipps, R.L.,
Introduction to Computer Graphics, Addison-Wesley, 1997.
[H1]

Hill, F.S. JR., Computer Graphics Using Open GL, Prentice Hall, 2001.

[LE1] Lengyel, Eric, Mathematics for 3D Game Programming & Computer


Graphics, Charles River Media, Inc., 2002.
[SH1] Schildt, Herbert, Java2, The Complete Reference, McGraw-Hill, 2001
[SE1] Schneider, Philip J., and Eberly, David H., Geometric Tools for Computer
Graphics, Morgan Kaufman Publishers, 2003.
[SP1] Shirley, Peter, Fundamentals of Computer Graphics, A K Peters, 2002.
[SJ1] Stewart, James, Calculus, Concepts and Contexts, second edition,
Brooks/Cole, 2001.
[TC1] Tremblay, Christopher, Mathematics for Game Developers, Thomson
Course Technology, 2004.
[VB1] Van Verth, James M. and Bishop Lars M., Essential Mathematics For
Games and Interactive Applications, A Programmers Guide, Morgan
Kaufmann Publishers, 2004.
133

134

BIBLIOGRAPHY

[WG1] Wall, David, and Gri th, Arthur, Graphics Programming with JFC,
Wiley, 1999.
[AW1] Watt, Alan, 3D Computer Graphics, Addison-Wesley, 2000.
[AW2] Watt, Alan, The Computer Image, Addison-Wesley, 1999.

You might also like