Game Development Reference
In-Depth Information
The purpose of all this vector manipulation is that, given three vertices
that are distinct and define a polygon, we can find a vector that extends
at right angles from this polygon. Given vertices A, B and C we can create
two vectors. N is the vector from B to A and M is the vector from B to C.
Simply subtracting B from A and B from C respectively creates these
vectors. Now the cross product of the vectors N and M is the normal of the
polygon. It is usual to scale this normal to unit length. Dividing each of the
terms by the magnitude of the vector achieves this.
Rotating the box
There are many options available when rotating a 3D representation of an
object; we will consider the three principal ones. The first option we will
look at uses Euler angles.
Euler angles
When considering this representation it is useful
to imagine an aeroplane flying through the sky.
Its direction is given by its heading. The slope of
the flight path is described using an angle we
shall call pitch and the orientation of each wing
can be described using another angle which we
shall call bank. The orientation can be com-
pletely given using these three angles. Heading
gives the rotation about the y -axis, pitch gives
rotation about the x -axis and bank gives rotation
about the z -axis.
To describe the orientation of an object we store an angle for the
heading, the pitch and the bank. Assuming that the rotation occurs about
the point [0, 0, 0] as the box is modelled then heading is given from the 3
Figure 1.5 Euler angle
3 matrix:
cos( h )
sin( h )
H =
-sin( h )
cos( h )
Search Nedrilad ::

Custom Search