Game Development Reference
In-Depth Information
11.3 Using Relaxation to Solve Systems of Equations
Verlet integration in itself, as described above, provides a good foundation for,
say, an unconstrained particle system. But how do we go about handling more
complex restrictions or constraints on the movements of the particles? How
should interconnected particles be handled, for example? And how do we keep
particles from penetrating a surface? As for the latter, we choose to simply project
offending particles out of obstacles. By projection, loosely speaking, we mean
moving the point as little as possible until it is free of the obstacle. Normally, this
means moving the point perpendicularly out towards the collision surface.
11.3.1 Handling Collisions and Penetrations
Let's look at a simple example. Assume that our world is the inside of the cube
(0 , 0 , 0)
(1000 , 1000 , 1000) and assume furthermore that the particles' restitu-
tion coefficient is zero (that is, particles do not bounce off surfaces when collid-
ing). To keep all particle positions inside the valid interval, the corresponding
projection code would be as follows:
// Keeps particles in a box
void SatisfyBoxConstraints( double x, int n) {
for ( int i=0; i
// For all particle coordinates
x = min(max( x, 0.0), 1000.0);
n; i++)
This keeps all particle positions inside the cube and handles both collisions and
resting contact. The beauty of the Verlet integration scheme is that the cor-
responding changes in velocity are handled automatically. Thus, after calling
SatisfyBoxConstraints() and VerletTimeStep() a number of times,
the velocity vector will contain no components in the normal direction of the sur-
face (corresponding to a restitution coefficient of zero). The update loop is then:
void UpdateLoop() {
Try it out—there is no need to directly cancel the velocity in the normal direc-
tion. While the above might seem somewhat trivial when looking at particles, the
strength of the Verlet integration scheme is now beginning to shine through and
Search Nedrilad ::

Custom Search