Game Development Reference

In-Depth Information

F
IGURE
9.3

The relative position of a car component.

relative to the origin. If the car is moved so that its origin is at

4

3
.
85

then its headlight will be at

1
.
5

−

4

3
.
85

5
.
5

3
.
1

+

=

0
.
75

This movement is called a “translation”: we are translating the car from one position

to another.

Rotations

The same thing occurs if the object is facing in a different direction. In figure 9.4 the

car has had its position and orientation altered.

So how do we calculate the location of the headlamp now? First we need to turn

the headlamp around to represent the direction in which the car is facing. We do this

by using a third version of our orientation value.

This time the orientation is expressed in matrix form. If you are unsure about

matrices, I'll return to their mathematics when we come to implementing matrix

classes for 3D in Section 9.2.3. You can skip the mathematics here unless you need a

refresher.