Game Development Reference
In-Depth Information
each coordinate direction. For example, under the three-dimensional Cartesian coordinate
system the velocity of an object could be separated into x-, y-, and z-components.
vvxvyvz
=++
(2.8)
x
y
z
The velocity vector, v , is on the left-hand side of Equation (2.8). The arrow symbol on top
of the v , x , y , and z terms in Equation (2.8) is used to indicate a vector. The terms v x , v y , and v z
are the velocity components in the x-, y-, and z-directions. The separate velocity components
are shown graphically in Figure 2-3.
v
z
v z
v y
v x
y
x
Figure 2-3. Velocity can be split up into directional components.
The reason to split a vector quantity such as velocity into its x-, y-, and z-components is
that it often makes it easier to model the physical problem. We will perform such “vector sepa-
rations” quite frequently throughout this topic. For example, when we study the motion of a
projectile in Chapter 5, the force, acceleration, and velocity of the projectile will be split into x-, y-,
and z-components. When we model a collision between two objects in Chapter 6, the collision
is modeled based on the directional components of velocity at the moment of impact.
Computing the Magnitude of a Vector
As we have discussed, sometimes a vector is divided into directional components. There are
times when you will need to go the other way—you may have the directional components of
velocity and need to compute the overall velocity magnitude. The magnitude of a vector is
found by taking the square root of the sum of the square of the directional components. For a
velocity vector in the Cartesian coordinate system, the velocity magnitude can be found from
the square root of the sum of the square of the x-, y-, and z-velocity components.
2
2
2
v
=++
v
v
v
(2.9)
x
y
z
The velocity magnitude of an object is also referred to as the speed of the object. You will
frequently need to compute vector magnitudes when incorporating physics into your games.
For example, aerodynamic drag is a function of the square of the velocity magnitude of an object.
The Unit Vector
In the previous section, you learned how to compute the magnitude of a vector. If the magni-
tude of a vector is equal to 1, the vector is known as a unit vector . Unit vectors are used when
splitting a vector into directional components. The x, y, and z terms in Equation (2.8) are unit
vectors in the x-, y-, and z-directions. We will use unit vectors several times in this topic, for
instance, when we calculate the lifting force caused by a spinning golf ball.
 
Search WWH ::




Custom Search