Rigid Body Physics Engine

previous next

The physics simulations shown on myPhysicsLab fall into two categories

  1. Specialized - designed for one particular mechanism
  2. General - uses the 2D rigid body physics engine which can simulate just about any configuration

An example in the "specialized" category is the cart + pendulum. That simulation works well, but it can only ever simulate that particular mechanism. You can vary the length of the pendulum, the mass of the objects, or spring stiffness. But you can't change how the parts are connected, or apply new forces, or collide with another object.

In contrast, the Rigid Body Physics Engine can model a wide variety of mechanisms. For example, here is the cart + pendulum using the physics engine. Notice that you can drag the cart or pendulum by pressing the mouse button to activate a spring force -- this is not possible in the specialized version of the simulation.

It is remarkable that the Rigid Body Physics Engine is able to model so many different mechanisms with good accuracy. Here are some more examples:

About the Physics Engine

The physics engine is composed of three classes that can be used separately (though we almost always use the last one).

  1. The RigidBodySim class handles moving rigid bodies by applying forces to them such as springs, gravity, damping. See Rigid Body Forces for the math.
  2. The ImpulseSim class extends RigidBodySim, adding collision handling. See Rigid Body Collisions for the math. See CollisionAdvance which manages the collision handling process.
  3. The ContactSim class extends ImpulseSim, adding contact forces that allow objects to push against each other. See Rigid Body Contact Forces for the math.

More information about how the rigid body physics engine works is described in several places:

previous next Valid HTML 4.01