Double Pendulum

P5 Javascript


One of my first attempts at exploring kinematics:

Double pendulums exhibit a strong chaotic behaviour due to their high sensitivity of initial conditions and thus pose as a great visual representation when researching Chaos Theory.

For the Double Pendulum we define the horizontal and vertical positions of pendulum mass, the angle of the pendulum, and the length of the rod. These variables are defined a second time for the second pendulum segment.

The points of mass are set to a randomized location and given an initial force, a gravitational constant, and a dampening factor. Two algebraic equations are then implemented to calculate the angle of each pendulum mass as it is moving.

A line is then drawn at the center of the second pendulum mass to visualize the movement trajectory and the color is interpolated based on the X location as a stylization touch.

You can refresh the page to see the pendulum start at different positions.