Most of the simulation web pages show how the math is derived. See for example the Single Spring simulation.

  • A physics simulation starts with a mathematical model whose variables define the state of the system at a given time. Each variable represents the position or velocity of some part of the system.
  • The heart of a physics simulation is the set of differential equations that describe how the variables evolve over time. The forces and geometry determine the equations.
  • The next step is getting the computer to solve the equations, a process that goes by the name numerical analysis. The Runge Kutta method is a popular choice.
  • For simulations that involve collisions there are additional steps: we need to detect the collision and then back up in time to the moment before the collision to modify the velocities.
  • Finally, there are lots of programming details about how to represent objects on the computer display, how to handle user input, how to synchronize with real time, and so on.
The rigid body physics engine is the most sophisticated simulation shown here. It is capable of replicating all of the other more specialized simulations. The physics engine handles collisions and also calculates contact forceswhich allow objects to push against each other.