velocity += acceleration*dt position += velocity*dtThis is a good first step, and many people stop there and discover that they are still left with large oscillation problems. This is due to the poor first-order integrator (Euler) and the lack of damping. Adding damping and velocity limiting will help:
velocity += acceleration*dt velocity = clamp(velocity, min, max) velocity *= dampen //eg: 0.98 position += velocity*dtHopefully your system is acting closer to how you expected. At this point if you still have some minor oscillation and odd edge cases you can probably solve them through more advanced techniques. If your still not getting a behaviour close to what you want then try a completely different approach.
The final quick and easy step to improve performance is to improve the integrator. A simple leap-frog (velocity-verlet) integrator will provide decent performance (no need to go to RK45!):
velocity += acceleration*dt velocity = clamp(velocity, min, max) velocity *= dampen //eg: 0.98 position += velocity*dt + 0.5*acceleration*dt*dtDone!
Now all your robot path-planning, navigation, graphics particle systems, and cloth-simulations will be up and running. Plenty of research papers to read if you want to keep improving it!
I'll leave you with this real life video illusion of marbles rolling up a slope:
No comments:
Post a Comment