Click and drag the bananas to a starting location, set the friction and spring strength, and click on the monkey to start. The bananas are subject to a restoring force proportional to their x position (F = -k*x) pushing/pulling them towards the vertical axis (as if a spring were connected between the bananas and the vertical axis. The monkeys track the position and velocity of the bananas
This program uses the same basic construct as many of my other programs: for every iteration through the main program loop, forces change the velocity, and the velocity changes the position. I decided do this program to show how dampened sine and cosine waves can be generated without using any trigonometric or exponential expressions. Instead, only a linear spring force proportional to the banana's position is applied, and sine waves emerge.