Oscillating Motion

Published February 12, 2018

For this week’s exploration into oscillating motion, I wanted to capture some of the playfulness and fun inherent in the chaotic motion of the double pendulum. Many incredible visuals online capture the mathematical complexity and underlying patterns to this motion, but I felt there were aspects of this motion that went unexplored. And so, beginning with the double pendulum, I looked at several ways to visualize this motion over time:

Eventually, I realized that another example I had looked at this week, that of a string (in the real-world sense, not the coding sense), very closely matched the type of motion I was seeing in the double pendulum. Using code from this example, the string was modeled as an ArrayList of Mover objects connected by Spring objects. To make it easier to work with as a single string object in my main code, I wrapped the Mover and Spring classes into a single SpringString class. This allowed me to add points to the end of a single SpringString object with a PVector and a starting force (to approximate the force with which they would be shot from the swinging pendulum end), as well as apply forces (such as gravity) to the object as a whole.

String with Mover objects hidden

String with Mover objects hidden

The wrapper SpringString class allowed me to implement this object in my main code with only the following code in my main sketch’s draw loop:

// approximate the acceleration force of bottom of the pendulum
float dx = x2-px2;
float dy = y2-py2;
PVector f = new PVector(dx,dy).mult(3);

// add a string point at bottom point with above force