Game Development Reference
In-Depth Information
Figure 1.8. Using Euler's method to approximate an orbit.
engines do just that for that reason), because of the nature of Euler's method the
error will still accumulate.
1.7.2 Higher-Order Explicit Methods
One solution to this problem is to realize that we are trying to approximate a non-
linear function with a linear function. If we take a weighted average of samples
of the derivative across our interval, perhaps we can construct a better approxi-
mation. The higher-order Runge-Kutta methods do just this. The most notable
example is Runge-Kutta Order 4, or just RK4, which takes four samples of the
derivative.
In general, RK4 will provide a better approximation of the function. However,
it does come with the cost of more invocations of the derivative function, which
may be expensive. In addition, it still does not solve our problem with stiff equa-
tions. For particularly stiff equations, RK4 will still add enough energy into the
system to cause it to spiral out of control. Fortunately, there are other possibilities.
1.7.3
Implicit Methods
One method uses an alternative definition of the derivative:
x ( t )
−
x ( t
−
h )
x ( t ) = lim
h→ 0
.
h
If we assume small h and again rearrange terms, we get
= x ( t
h )+ h x ( t ) .
x ( t )
−
Substituting t + h for t , we end up with
= x ( t )+ h x ( t + h ) .
x ( t + h )
 
Search Nedrilad ::




Custom Search