Game Development Reference
Here, invmass1 and invmass2 are the numerical inverses of the two masses.
If we want a particle to be immovable, simply set invmass =0for that particle
(corresponding to an infinite mass). Of course, in the above case, the square root
can also be approximated for a speed-up.
11.4 Rigid Bodies
The equations governing motion of rigid bodies were discovered long before the
invention of modern computers. To be able to say anything useful at that time,
mathematicians needed the ability to manipulate expressions symbolically. In the
theory of rigid bodies, this led to useful notions and tools such as inertia tensors,
angular momentum, torque, quaternions for representing orientations, etc. How-
ever, with the current ability to process huge amounts of data numerically, it has
become feasible and in some cases even advantageous to break down calculations
to simpler elements when running a simulation. In the case of three-dimensional
rigid bodies, this could mean modeling a rigid body by four particles and six con-
straints (giving the correct amount of degrees of freedom, 4
simplifies many things.
Consider a tetrahedron and place a particle at each of its four vertices. In
addition, for each of the tetrahedron's six edges, create a distance constraint like
the stick constraint discussed in the previous section. This configuration suffices
to simulate a rigid body. The tetrahedron can be let loose inside the cube world
from earlier, and the Verlet integrator will then move it correctly. The function
SatisfyConstraints() should take care of two things: (1) that particles
are kept inside the cube (like previously) and (2) that the six distance constraints
are satisfied. Again, this can be done using the relaxation approach; three or four
iterations should be enough with optional square root approximation.
Inside the cube world, collisions are handled simply by moving offending
particles (those placed at the tetrahedron vertices) such that they do not intersect
with obstacles. In a more complex setting than the cube world, however, the sides
of the tetrahedron may also intersect with obstacles without the particles at the
vertices themselves being in invalid positions (see Figure 11.2 ).
In this case, the vertex particles of the tetrahedron, which describe the posi-
tion of the rigid body, must be moved proportionally to how near they are to the
actual point of collision. If, for example, a collision occurs exactly halfway be-
tween particles x 1 and x 2 , then both these particles should both be moved by the
same amount along the collision surface normal until the collision point (which
is halfway between the two particles) has been moved out of the obstacle (see