Coding Challenge 93: Double Pendulum
915,647
Published 2018-02-13
š¹ļø p5.js Web Editor Sketch: editor.p5js.org/codingtrain/sketches/jaH7XdzMK
š„ Previous video: Ā Ā Ā ā¢Ā CodingĀ ChallengeĀ #92:Ā XORĀ ProblemĀ Ā
š„ Next video: Ā Ā Ā ā¢Ā CodingĀ ChallengeĀ #94:Ā 2048Ā -Ā PartĀ 1Ā Ā
š„ All videos: Ā Ā Ā ā¢Ā CodingĀ ChallengesĀ Ā
References:
š“ Physics Lab Double Pendulum: www.myphysicslab.com/pendulum/double-pendulum-en.hā¦
Videos:
š Pendulum Simulation: Ā Ā Ā ā¢Ā 3.4:Ā PendulumĀ SimulationĀ -Ā TheĀ Nature...Ā Ā
š“ Coding Train Live 120: Ā Ā Ā ā¢Ā LiveĀ StreamĀ #120:Ā MNISTĀ andĀ PendulumsĀ Ā
Related Coding Challenges:
š #86 Cube Wave by Bees and Bombs: Ā Ā Ā ā¢Ā CodingĀ ChallengeĀ #86:Ā CubeĀ WaveĀ byĀ Be...Ā Ā
š #159 Simple Pendulum Simulation: Ā Ā Ā ā¢Ā CodingĀ ChallengeĀ #159:Ā SimpleĀ Pendulu...Ā Ā
Timestamps:
0:00:00 Double Pendulum Simulation
0:03:45 Creating The Double Pendulum
0:08:35 Adding The Tracing of The Path
0:12:51 Implementing The Double Pendulum Formulas
0:24:45 Visualizing It
0:28:21 Adding Damping
0:29:16 Conclusions And Suggestions
Editing by Mathieu Blanchette
Animations by Jason Heglund
Music from Epidemic Sound
š Website: thecodingtrain.com/
š¾ Share Your Creation! thecodingtrain.com/guides/passenger-showcase-guide
š© Suggest Topics: github.com/CodingTrain/Suggestion-Box
š” GitHub: github.com/CodingTrain
š¬ Discord: thecodingtrain.com/discord
š Membership: youtube.com/thecodingtrain/join
š Store: standard.tv/codingtrain
šļø Twitter: twitter.com/thecodingtrain
šø Instagram: www.instagram.com/the.coding.train/
š„ Coding Challenges: Ā Ā Ā ā¢Ā CodingĀ ChallengesĀ Ā
š„ Intro to Programming: Ā Ā Ā ā¢Ā StartĀ learningĀ here!Ā Ā
š p5.js: p5js.org/
š p5.js Web Editor: editor.p5js.org/
š Processing: processing.org/
š Code of Conduct: github.com/CodingTrain/Code-of-Conduct
This description was auto-generated. If you see a problem, please open an issue: github.com/CodingTrain/thecodingtrain.com/issues/nā¦
#doublependulum #pendulumharmonicmotion #processing
All Comments (21)
-
13:15 Note: the following proof is trivial and has been left as an exercise to the reader
-
āG is the universal gravitational constant, I assume. Thatās just gonna be one.ā
-
Fun fact in case nobody else has mentioned it: updating the positions using the "current velocity" vs the previous one changes the numerical method from Euler's method to the Euler-Cromer method, which is quite a lot more accurate. The regular Euler method is prone to inadvertently increasing the energy of the system, while the Euler-Cromer method conserves energy quite decently. The two methods seem almost identical, but the behind the scenes math is quite interesting and shows that they are actually of different orders.
-
"Okay, I'm gonna see if I can just copy and paste this enormous differential equation right into my code."
-
To those who want to make this simulation more real do this. Currently Dan is setting g = 1. Although its far from the actual value the simulation looks very real. This is because one second in the simulation is one frame. And by default processing or p5.js is set to 60 fps. This means when one second passes in real world, 60 seconds would have passed in the simulation world. Hence the correct value of g would be 9.8/ ( 60 * 60 ) . There's still one more thing to adjust. The masses are actually in kilograms hence you should set the value of bob masses to around 0.05 which is 50 grams. Also, the lengths are in meters so make that they aren't very large.
-
OMG, I've watched a 30 min video without even noticing it. Thanks for existing, Dan!
-
I really REALLY laughed when the pendulum just started warping into another dimension at 12:30 "See, this is kind of the idea"
-
i have no idea wats going on. yet im enjoying this video.
-
I never knew i could be so engaged and laugh at someone doing something like this. Great video! :)
-
I'm so happy you've done this; I started making one of these in P5 using a class, and I just figured you'd use basic Trig to calculate the angles. Had literally no idea the lre was a huge algorithm derived for it! Gonna give this a looking soon!
-
24:10 you are changing the integration method from simple explicit Euler to symplectic Euler which is numerically much more stable.
-
We need more teachers like you, I'm starting to enjoy coding thanks to you!
-
this is the first of your videos i have seen, i am so glad people actally go through these sort of things for others to see keep up the good work :)
-
I think a cool feature to add would be a fade of the trace line, so as a segment of line is drawn, say 5 seconds later it begins to fade, so you only ever have the last 5 or so seconds of trace at any given time
-
Youāre one of those special people in the world that make it a better place. You can always tell, and it just radiates from you.
-
First video I watch from this genius. Youāre funny as hell, your channelās gonna get me hooked. Thanks.
-
Idk why this was recommenced to me, I never even coded, but you're so full of energy and entertaining, thumbs up dude
-
THIS IS A PERFECT EXAMPLE OF HOW TO DO AND HANDLE COMPLEX PROJECTS AND COMPLEX ALGORITHM. YOU'RE GREAT!!
-
you are a blessing !!!! a true blessing. I cant thank you enough for what you are doing.
-
Pretty cool! A few things: the dampening should be a function of velocity, proportional using some constant. It would be harder/maybe fun to calculate the forces along the bars and have them extend elastically under the load.