Double Pendulum

Finally, the double pendulum seems to be working pretty well :heart_eyes:

Of course the code used is from Daniel Shiffmann from Daniel Shiffman at The Coding Train.

Seems the problem was indeed that the formulas require radians, but since Vuo require degrees for Sin & Cos, the acceleration and velocities where too high, spinning the whole thing out of control.
A degree to radian seems to fix it.

Code used : GitHub
YouTube Video : Coding Challenge #93: Double Pendulum

Next will be some damping and maybe drag and release the pendulum with the mouse.

Any critics or optimization welcome.

MIT License

Double Pendulum - 2022.12.26.vuo (22.9 KB)



1 Like

Thanks @jersmi ;)

It’d be nice to have a bit of clarity interacting with the physical forces like gravity and mass. Not esp. clear when changing those parameters. It’s like the system in underwater or something. Edit: I just saw in the YouTube comments that someone was addressing actual units – meters for radius, kg for mass, and some formula for gravity based on fps. It’d be nice to get more precise with this…  

@jersmi hehe ;)
It took me so long to get this code into nodes, that I’m not sure I want to dive back into it ;)
At least not right now.
But yes it could still receive more work. Wanted to add the possibility to drag and drop the pendulum position with the mouse, change a value without having to restart the composition etc.

1 Like

this is great fun. I put a switch onto the pendulum image to hide/show it with a click on the keyboard.

3D version?!!  


@useful_design haha great ;)

3D version ? You’re welcome to :grimacing::joy: Or maybe a fake 3D that applies a noise movement onto the Z axis already ;)

You can also try a triple pendulum :grimacing: or maybe I thought about simply attaching a second double pendulum at the end of the first pendulum (not mathematically with the right formulas, but just with coordinates).

Good luck ;)


I stopped studying higher level maths over 30 years ago! I’ll leave it for someone else to win the fame :sweat_smile::joy:

1 Like

@bodysoulspirit, I adapted your approach here to Audulus (modular audio software with Lua-based vector graphics), took me about 20 minutes with your clear approach, which means you did indeed do the difficult part :sweat_smile:. When I did get it running in Audulus I realized that since this is a chaotic system, you need to be careful not to apply out of range parameters otherwise it’ll devolve into complete chaos. In this comp you choked it to 60 fps, which solves one problem. Adding the interaction you mention and refining parameter limits around physical units would definitely enhance the illusion.

Idk, maybe a 3D version wouldn’t be that unapproachable. The github formulas are separated into different sections instead of one expression. That might help make it easier to comprehend.  

1 Like

@jersmi ;)
Ah yes, some limits should be good.
Doable in Vuo so that out or range parameters applied in Audulus automatically get clamped from within the composition.
And yes, indeed, I’ve played a bit with other parameters and the results can go crazy or be bad.
I’m not sure if there some errors in my composition, or if it’s just the chaotic system, should maybe compare with online examples in Processing that The Coding Train links to.

I’ve spent so much time on this, that once I got a satisfied result, I didn’t dive any deeper. Also don’t have the time recently :(

And regarding the splitted sections of the expressions, if we’re talking about the same thing, I remember trying to use these when debugging, but to split the formula into several nodes, I ended up with too much more nodes, and in the end if was easier to use one formula ;)

Thanks, take care ;)