Game Development Reference

In-Depth Information

two-dimensional games a vector representation is useful, but the mathematics for

angles alone isn't
so
difficult that you couldn't stick with the angle and adjust the

surrounding code to cope.

Not surprisingly there are similar problems in three dimensions, and we will end

up with a representation for orientation that is not a common bit of mathematics you

might learn in high school. In three dimensions, however, the obvious representation

is so fundamentally flawed that it is almost impossible to imagine providing the right

workarounds to get them running.

I don't want to get bogged down in representations that
don't
work, but it is worth

taking a brief look at the problems before we look at a range of improving solutions.

9.2.1

E
ULER
A
NGLES

In three dimensions an object has three degrees of freedom for rotation. By analogy

with the movement of aircraft we can call these yaw, pitch, and roll. Any rotation of

the aircraft can be made up of a combination of these three maneuvers. Figure 9.5

illustrates them.

For an aircraft these rotations are about the three axes:
pitch
is a rotation about

the X axis,
yaw
is about the Y axis, and
roll
is about the Z axis (assuming an aircraft is

looking down the Z axis, with the Y axis up).

Recall that a position is represented as a vector, where each component repre-

sents the distance from the origin in one direction. We could use a vector to represent

rotation, where each component represents the amount of rotation about the corre-

sponding axis. We have a similar situation to our two-dimensional rotation, but here

we have three angles, one for each axis. These three angles are called “Euler angles.”

This is the most obvious representation of orientation. It has been used in many

graphics applications. Several of the leading graphics modeling packages use Euler

F
IGURE
9.5

Aircraft rotation axes.