Game Development Reference
In-Depth Information
As shown in Equation (5.1) the derivative of velocity with respect to time is equal to accel-
eration. As we saw in Chapter 4, if an expression for the acceleration is known, then the velocity
of the projectile can be found by integrating Equation (5.1).
v
−=
v
adt
(5.5)
0
The quantity v 0 is the initial velocity of the projectile. If the acceleration is zero, as it is for
the x- and y-directions, then the integral shown on the right-hand side of Equation (5.5) is
equal to zero. If the acceleration is constant, the integral is equal to the constant acceleration
multiplied by time. From these two facts, the equations for the velocity of the projectile under
the gravity-only model can be determined and are shown in Equation (5.6).
vv
=
(5.6a)
x
x
0
vv
=
(5.6b)
y
y
0
vv t
=−
(5.6c)
z
z
0
The quantities v x0 , v y0 , and v z0 in Equations (5.6a) through (5.6c) are the initial velocities in
the x-, y-, and z-directions at time t = 0. The x- and y-velocity components are constant at all
time under the gravity-only model. This situation reflects Newton's first law of motion, which
states that the velocity of an object will remain constant unless acted upon by an external force,
and there are no x- or y-direction forces in the gravity-only model. The z-component of velocity
will change over time, its value becoming increasing negative as gravity pulls the projectile
towards the ground.
Location Equations
The location of the projectile at any time can be computed if the velocity of the projectile is
known because the derivative of location with respect to time is equal to the velocity. The
location as a function of time can be computed by integrating Equation (5.2).
ss
−=
t
(5.7)
0
The expressions that determine the x-, y-, and z-locations of a projectile according to the
gravity-only model are shown in Equation (5.8). The x 0 , y 0 , and z 0 parameters are the initial x-,
y-, and z-locations of the projectile at time t = 0.
xx vt
=+
(5.8a)
0
x
0
yy yt
=+
(5.8b)
0
x
0
1
2
2
zz vt
=+ −
t
(5.8c)
0
z
0
Because the x- and y-velocities are constant, the x- and y-locations of the projectile change
at a constant rate. The equation for the z-location shown in Equation (5.8c) is what is known as
a quadratic equation . The rate of change of z-location is constantly increasing as the projectile
accelerates towards the ground.
Search WWH ::




Custom Search