Game Development Reference
In-Depth Information
Just as for two-dimensional rotation, we have fixed the problem of messy bounds-
checking by adding an extra value to our representation, adding a constraint to re-
move the extra degree of freedom, and making sure we only get rotations.
In the same way that normalizing our two-dimensional vector representation gave
us a point on a circle, normalizing a quaternion can be thought of as giving a point on
the surface of a four-dimensional sphere. In fact, lots of the mathematics of quater-
nions can be derived based on the surface geometry of a four-dimensional sphere.
While some developers like to think in these terms (or at least claim they do), per-
sonally I find four-dimensional geometry even more difficult to visualize than three-
dimensional rotations, so I tend to stick with the algebraic formulation I've given
here.
9.3
A NGULAR V ELOCITY AND A CCELERATION
Representing the current orientation of rigid bodies is only one part of the problem.
We also need to be able to keep track of how fast and in what direction they are
rotating.
Recall that for two dimensions we could use a single value for the angular velocity
without the need to perform bounds-checking. The same is true of angular velocity
in three dimensions. We abandoned the scaled axis representation for orientations
because of the boundary problems. Once again, when we are concerned with the
speed at which an object is rotating, we have no bounds: the object can be rotating as
fast as it likes.
Our solution is to stick with the scaled axis representation for angular velocity.
It has exactly the right number of degrees of freedom, and without the problem of
keeping its angle in bounds, the mathematics is simple enough for efficient imple-
mentation.
The angular velocity is a three-element vector that can be decomposed into an
axis and rate of angular change:
θ
=
r
a
where
a is the axis around which the object is turning and r is the rate at which it is
spinning, which (by convention) is measured in radians per second.
The mathematics of vectors matches well with the mathematics of angular veloc-
ity. In particular, if we have an object spinning at a certain rate, θ ,andweaddtoits
rotation a spin at some rate in a new direction, ω , then the new total angular velocity
will be given by
θ
= θ
+
ω
In other words, we can add two angular velocities together using vector arithmetic
and get a new, and correct, angular velocity.