9
Introducing Dynamics Simulation 709
This figure il lustrates what we would like to
achieve. Over a period of time the cannon ball’s
rate of ascent should slow due to gravity, and
it should eventually fall to the ground having
traveled through a classic parabolic arc (assuming
no air resistance).
At a given point in time we can examine the state
of the ball (its speed v and acceleration a)and
knowing the external forces act ing on it we can
mak e a guess as to its change in position after
a period of time has elapsed (call this period h
seconds). This guess is a combination of a number
of factors:
• WeassumethatNewton’slawsofmotion
govern the motion of the ball
• Weassumethatinthetimeperiodh all the
external forces acting on the ball are constant,
so air resistance and wind and gravity do not
change during this time.
• We assume that the math we use to calculate the
new position is accurate
In general, the first assumption is usually valid,
except at relativistic or quantum sc a les, which we
canassumeshouldbehandledbyothersystems.
The remaining two, however, cause problems and
arecloselylinkedtothetimeperiodh over which
we’re performing the calculations. We’ll now
examinetheeffectofthesizeofthistimeperiod
on the accuracy of the simulation.
Time Steps
In general, the forces acting on an object are rarely
truly constant; gravity is close to being constant,
butmostotherforceslikewindandairresistance
are not. So, taking the cannon ball example,
imagineawindylayerintheatmospherethatthe
cannon ball passes through, as shown in the next
figure.
Inthesimulationontheleftweassumewe’re
taking steps of one second; this is actually a
relatively large interval for a physics simulation,
butisusedheretoillustratethepoint.Weknow
all the forces acting on the ball at time t1 so we
usesomemathtopredictthenewpositionand
velocity at time t2, after one second has elapsed.
During this period, we assume that the w ind force
acting on the ball is constant. In this example,
we’ll calculate the new position above the region
of high wind, s o we’ll effectively have missed the
windy bit by taking too great a jump. In the second
exampleontheright,we’reusingtimestepsof½
second. In this case, after determining the new
position at time t2 we find the ball in the middle
ofthewindyregion. Thisregioncausesalarge
windforcetoactontheballwhichistakeninto
account during the next time step. At that point we
reevalua te the math and determine a new position
fortheballattimet3.Thisisdifferentfromthe
position determined in the simulation on the left,
even though the same amount of time has been
simulated in each case. In other words, the wind
has blown the ball to the lef t a bit and has reduced
the velocity of the ball
Ingeneral,thesmallerthetimesteptaken,the
moreaccuratetheresultattheendofthetimestep.
Thus, to step forward in t ime by a large time step