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 forces which allow objects to push against each other. site
A "roller coaster" for two masses connected by a spring. page
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.
A personal project carried to an impressive conclusion over many years and multiple web technologies.