Game Development Reference
In-Depth Information
Vector Representing Direction
A vector can also represent a direction. A vector that is of length or magnitude 1 is called a unit
vector (see Figure 3-3 ). Unit vectors are important because you can set properties such as an
object's velocity or the force acting on an object by first finding the unit vector of the direction
vector you want the object to move in, then multiplying this unit vector by a number. This number
represents the magnitude of the speed of the object or the force you want to apply to the object.
The final vector would contain both the direction of the object or direction of the force and also the
speed of the object or amount of force to apply to the object.
y
This vector is a unit
vector of length 1
( 1,0, 0 )
x
Figure 3-3. Unit vector representing a direction
Vector Representing Rotation Axis
A vector can also represent the axis of rotation of an object. The axis of rotation is the line about
which an object rotates. In the Orientation class in Chapter 2, the variable m_RotationAxis is the
local axis about which the object rotates.
private Vector3 m_RotationAxis;
See Figure 3-4 for a graphical representation of the local rotation axis.
y
Rotation Axis Vector
(6, 6,-6)
y
x
z
x
Figure 3-4. Vector representing a rotation axis of an object
 
 
Search WWH ::




Custom Search