Verlet Integration
Earlier in this chapter, we discussed how and why Euler Integration becomes less stable over time. We provided a better way to integrate position, Velocity Verlet Integration. While better than Euler Integration, the new method provided can become unstable too. In this section, we will discuss in detail implementing a more stable integration method: Verlet Integration.
Getting ready
In order to move particles using Verlet Integration, we need to re-implement both the Update
and SolveConstraints
methods of the Particle
class. We need to re-implement these functions in a way that finds the velocity of a particle using the previous and current positions of the particle.
How to do it…
Follow these steps to replace the Euler Integration of the Particle
class with Verlet Integration:
- Remove the
velocity
variable from the definition of theParticle
class inParticle.h
. - Re-implement the
Update
method of theParticle
class inParticle.cpp
. This new implementation will perform...