The multi-pendulum is a classic example of a chaotic system. Even with the simplest starting conditions, it quickly becomes nearly impossible to predict. This simulation models a pendulum with 5 masses, using Matthias Müller's Position Based Dynamics framework.


The equations describing a pendulum get complicated quickly, so it's best to avoid them. The trick to modeling a pendulum like this isn't to find equations that govern its motion, but to find a way to model rigid behavior in general, and then apply it to this problem. The Position Based Dynamics framework has stood the test of time for modeling physical systems, and it can be easily applied to a pendulum.


The fundamental idea behind Position Based Dynamics is that each weight in our pendulum shuold maintain a constant distance from its neighbors. If at the start of the simulation, each weight is one meter apart, then every subsequent frame, we move it so it's always one meter apart from each of its neighbors. If we do this for each weight a few times per frame, we can get a realistic-looking simulation with minimal computation. This concept of maintaing a constant distance is called a distance constraint.

Position Based Dynamics isn't just useful for pendulums, though. It can be used to model just about anything, including cloth, buildings, fluids, vehicles, Here on my website, I used it to model water flowing in a box.