Game Development Reference
In-Depth Information
Figure 7-5. Unstable results using Euler's method
It's clear from the figure that using Euler's method yields terribly unstable results. You
can see how the motion amplitude continues to grow. If this were a game, say, where
you have a few objects connected by springs interacting with one another, then this sort
of instability would manifest itself by wildly unrealistic motion of those objects. Worse
yet, the simulation could blow up, numerically speaking.
Often, your choice of step size affects stability where smaller step sizes tend to eliminate
or minimize instability and larger steps aggravate the problem. If you're working with
a particularly unwieldy function, you might find that you have to decrease your step
size substantially in order to achieve stability. This, however, increases the number of
computations you need to make. One way around this difficulty is to employ what's
called an adaptive step size method , in which you change your step size on the fly de‐
pending on the magnitude of a predicted amount of truncation error from one step to
the next. If the truncation error is too large, then you back up a step, decrease your step
size, and try again.
One way to implement this for Euler's method is to first take a step of size ∆ t to obtain
an estimate at time t + ∆ t , and then take two steps (starting from time t again) of size
t / 2 to obtain another estimate at time t + ∆ t . Since we've been talking velocity in the
Search Nedrilad ::

Custom Search