Game Development Reference
In-Depth Information
// Calculate the new velocity at time t + dt
// where V is the velocity at time t
Vnew = V + (k1 + 2*k2 + 2*k3 + k4) / 6;
// Calculate the new displacement at time t + dt
// where S is the displacement at time t
Snew = S + Vnew * dt;
// Update old velocity and displacement with the new ones
V = Vnew;
S = Snew;
}
To show you how accuracy is improved over the basic Euler method, we've superim‐
posed integration results for the ship example using these two methods over those
shown in Figure 7-2 and Figure 7-3 . Figure 7-6 and Figure 7-7 show the results, where
Figure 7-7 is a zoomed view of 7-6.
Figure 7-6. Method comparison
 
Search Nedrilad ::




Custom Search