Game Development Reference

In-Depth Information

It's all very well combining angular velocities, but we'll also need to update the

orientation by the angular velocity. For linear updates we use the formula

p
=

+
¨

p

p
t

We need some way to do the same for orientation and angular velocity: to up-

date a quaternion by a vector and a time. The equivalent formula is not much more

complex:

t

2

θ

ˆ

=

θ

ˆ

+

ω

ˆ

θ

ˆ

where

⎡

⎣

⎤

⎦

0

θ
x

θ
y

θ
z

ω

ˆ

=

which is a quaternion constructed with a zero
w
component and the remaining com-

ponents are taken directly from the three components of the angular velocity vector.

The constructed quaternion
ω

ˆ

doesn't represent an orientation, so it shouldn't be

normalized.

I hope you agree that this is really quite painless. We can benefit from the best of

both worlds: the ease of vectors for angular velocity and the mathematical properties

of quaternions for orientations.

9.3.1

T
HE
V
ELOCITY OF A
P
OINT

In section 9.1.3 we calculated the position of part of an object even when it had been

moved and rotated. To process collisions between objects, in chapter 14 we'll also have

to calculate the velocity of any point of an object.

The velocity of a point on an object depends on both its linear and angular veloc-

ity:

=
θ

˙

×

−

+ ˙

q

(
q

p
)

p

[9.5]

˙

where

q
is the velocity of the point,
q
is the position of the point in world coordinates,

p
is the position of the origin of the object, and
θ
is the angular velocity of the object.

If we want to calculate the velocity of a known point on the object (the mirror on

the side of the car, for example), we can calculate
q
from equation 9.2.

9.3.2

A
NGULAR
A
CCELERATION

Because angular acceleration is simply the first derivative of angular velocity, we can

use the same vector representation in both acceleration and velocity. What is more,