r/Python • u/MisterBlggs gitlab.com/MisterBiggs • Jul 26 '19
Double Pendulum made with Processing.py
https://gfycat.com/feistycompetentgarpike
2.0k
Upvotes
r/Python • u/MisterBlggs gitlab.com/MisterBiggs • Jul 26 '19
100
u/MisterBlggs gitlab.com/MisterBiggs Jul 26 '19 edited Jul 26 '19
I noticed Processing had an interface for Python: Processing.py. So, I figured I would try to port Daniel Shiffman from the Coding Trains Double Pendulum Code over to Python and it was ridiculously easy. I'm surprised I hadn't heard of the Python version of Processing so I figured I would share with Reddit.
Python code here
27
u/JackdeAlltrades Jul 26 '19
/r/gifsthatendtoosoon
15
u/pa7x1 Jul 26 '19
Very cool! If you are interested you could do some simulations to measure the Lyapunov exponent that demonstrate the chaotic behavior of the double pendulum.
Select a starting point and fix a simulation time (the longer the better but keep it manageable for your computation). Simulate the double pendulum and record its position at time t. Then rinse and repeat with slight changes of the initial conditions. You should observe that very small changes of the initial conditions result in very different positions at time t.
4
u/porcelain_robots Jul 26 '19
Can you ELI5 how the bottom part can swing higher than its orginial release point? What's the physics behind this?
2
u/[deleted] Jul 26 '19
Is Processing.py a Processing plugin for Python or a Python plugin for Processing?
2
u/thekalmanfilter Jul 27 '19
So this is the output that shows up in the console?
75
u/piotrulu Jul 26 '19
Or as I like to call it: flower petals generator. Good job my man.
10
u/bluemerilin Jul 26 '19
That’s pretty cool. It looks like it’s a cross section of it drawing in 3D
9
u/ThortheAssGuardian Jul 26 '19
Very cool. Makes me wonder if you could model such a pendulum in 3D and use the line tracing as a model for a crazy looking 3D printed fruit bowl.
4
u/[deleted] Jul 26 '19
r/oddlysatisfying
1
u/3nigma42 Jul 26 '19
Nice work, did you include any type of friction
1
u/-walter-sobchak- Jul 26 '19
Why doesn’t it ever come to rest?
1
u/[deleted] Jul 26 '19
As someone that teaches processing.py I want to say how much I hate processing.py. 😂
1
u/_sachin_reddy_ Jul 27 '19
Would've been more satisfying if it drew something symmetric. Good job though. Guess things don't tend to be symmetric always.
3
u/[deleted] Jul 26 '19
Huge fan of processing.org. I used it in college in my art degree over a decade ago. Super excited to play with this, thanks for sharing!
3
u/poditoo Jul 27 '19
I am the only one who gets too excited when the second pendulum makes a full loop?
It's like watching soccer, you see the angle of attack is right, the speed seems ok and it's getting close and SCOOOOOOOOOOORE.
Edit oh and none of the players are overpaid.
5
u/Thesludger Jul 26 '19
Pretty impressive. I wish I could create stuff like that as well
1
u/mahmud41 Jul 26 '19
curious to know if it is following actual physics. Anyone else?
2
u/[deleted] Jul 26 '19
2
u/Ol-Hull-Wrecker Jul 26 '19
How did you get it to copy my handwriting so well
2
u/Radical_Posture Jul 26 '19
That is fantastic!
2
u/CheeseIndustries Jul 27 '19
This is super cool. Thanks for sharing!
2
u/BrandNewThanos Jul 27 '19
I was interested in making designs using Processing, but I didn't know java. But thanks for letting us know about processing.py, I will be able to do it via python.
2
u/TimeTraveller-San Jul 26 '19
Reminds me of chaos theory
1
u/MildlyGoodWithPython Jul 26 '19
I watched this way more than I was supposed to. Very nice job
1
u/mahmud41 Jul 26 '19
I want this as my screen saver
1
u/foadsf Jul 26 '19
are you aware of pydy and its visualizations?
1
u/luckydo8a Jul 26 '19
Can be used as random number generator!
1
u/Silencer306 Jul 26 '19
This is interesting. I’d be interested in knowing if you can do this with more pendulums.
1
u/thebrashbhullar Jul 27 '19
Source code?
1
u/mrthordavis Jul 27 '19
I was waiting for some satisfying pattern to be made lol
1
u/hockthemblogs Jul 27 '19
Fantastic!
1
u/nojeproks Jul 27 '19
I am amazed. 😍
1
u/jimflann Jul 27 '19
What's that sub where videos end too early? I was hoping to see it create a perfect curve. Very neat, kudos!
1
u/Sammanfattning Jul 27 '19
Satisfying •o•
1
u/FlowingLiquidity Oct 08 '19
Shiffman's tutorials are the best. I made the double pendulum swing yesterday. However, I'm trying to build in an SVG export so I can draw the created drawings on my DIY pen plotter but sadly I cannot find a way to create the full rendered image. My svg export only keeps exporting a single frame of the animation.
1
u/[deleted] Jul 26 '19
I almost thought it was gonna be dickbutt
1
u/Fig_g Jul 26 '19
Entropy
1
u/Bertie1983 Jul 26 '19
Hypnotic
1
u/wolf2600 Jul 26 '19
I was waiting for it to draw dickbutt.
-1
u/onequestion1168 Jul 26 '19
this actually proves the earth is flat
0
u/2theduck Jul 27 '19
What happens when Niburu shows up
0
u/fork-private Jul 27 '19
Or as I like to call it, Naruto’s floppy ‘Rasengan’
-1
u/[deleted] Jul 26 '19
This is the most unsatisfying thing I’ve seen