|
|
arctwelve wrote:
I'm trying to implement Verlet integration as described in Jakobsen's paper. I noticed something odd when I changed the timestep value in the integrator: not just the speed changed, but also the motion of my particle.
To set my particle in motion I set it's current position slighly different than its previous position, as described in the article. Let's say in 2D I set the previous pos lower and to the left of the current pos. Then the particle moves in an upward arc to the right. At lower timesteps the arc it travels is longer.
Is this supposed to happen? When I use euler Im used to changes in speed (and accuracy) but the motion remains fairly consistent.
No, that should not happen.
There are two places to set time values with (velocity-less) Verlet: the time value used in updating forces=>acceleration (dt squared), and the time value used to update the simulation loop.
1. Use a fixed timestep: update the simulation N times between graphic updates. Keep track of the delta-time remainder (since you can only perform N integer update counts) for the next physics-graphics loop. You can also run the simulation in a thread at a fixed rate (in Win32, you can use WaitForSingleObject() with an appropriate timeout to wake the thread at the desired rate). 2. Make sure that you update both time values.
You should see little difference in behavior going between (for example) 50-100Hz (springs will show the most change). If you change the time values while running, you should only see a small jump in motion, after which motion should look very similar to the previous timestep.
I performed experiments switching between Euler, RK2 (midpoint,), RK4 (Runge-Kutta), and Verlet. Changing the simulation time did not show a major difference in (basic) motion between the various methods (springs, stiff systems, and high angular velocities show the most (visible) change between integration methods).
|