Coding Challenge 93: Double Pendulum

preview_player
Показать описание


References:

Videos:

Related Coding Challenges:

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

#doublependulum #pendulumharmonicmotion #processing
Рекомендации по теме
Комментарии
Автор

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.

RedTriangle
Автор

13:15
Note: the following proof is trivial and has been left as an exercise to the reader

sarath_sajan
Автор

"Okay, I'm gonna see if I can just copy and paste this enormous differential equation right into my code."

Phi
Автор

OMG, I've watched a 30 min video without even noticing it. Thanks for existing, Dan!

joaovitordasilvabonadiman
Автор

I really REALLY laughed when the pendulum just started warping into another dimension at 12:30
*"See, this is kind of the idea"*

lepetrolophiledu
Автор

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.

AdityaFingerstyle
Автор

i have no idea wats going on. yet im enjoying this video.

photon
Автор

“G is the universal gravitational constant, I assume. That’s just gonna be one.”

missingsemi
Автор

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

TheUltimateVanquish
Автор

24:10 you are changing the integration method from simple explicit Euler to symplectic Euler which is numerically much more stable.

matthimf
Автор

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.

TheDyingPlant
Автор

We need more teachers like you, I'm starting to enjoy coding thanks to you!

MicheleMerlino-ybog
Автор

I never knew i could be so engaged and laugh at someone doing something like this. Great video! :)

ayjaygame
Автор

There is a small error here in the equations of motion. Because the canvas draws the origin in the top left, the derivation used here is slightly wrong. This is accounted for in drawing the pendulum. However the error propagates into the angular acceleration equation.

There are two ways to fix this:

1) Fix the equations of motion by doing a coordinate transformation of the solution

g -> -g, and cos(angle1) and cos(angle2) also go to negatives. This is actually a bit harder than it looks because there are a lot of trig identities you'd need to pull out to di this.

2) Fix the coordinate system

When I implemented this myself using plain old JavaScript the Canvas Context object allows you to scale it by a negative number. Then fix how you draw the pendulums so y = -cos(angle) * length. I believe a way to accomplish this in Processing would be the rotateX() function.

ssbmwine
Автор

"I'm not going to derive those formulas" *cries in physics major

taylorjeffery
Автор

17:49
"Oh I forgot a semi colon"

Me: (Laughs in Python)

nathannolte
Автор

The first time i see, why i had to learn all the Math in school xD

blutstein
Автор

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!

DowzerWTP
Автор

THIS IS A PERFECT EXAMPLE OF HOW TO DO AND HANDLE COMPLEX PROJECTS AND COMPLEX ALGORITHM. YOU'RE GREAT!!

klivecorps
Автор

Idk why this was recommenced to me, I never even coded, but you're so full of energy and entertaining, thumbs up dude

tryphonunzouave