DoublePendulum
DoublePendulum copied to clipboard
Simulation breaks when the two pendulums are on opposing sides of the anchor.
- Lift the middle ball up and to the right, above the anchor point.
- When you let go, the simulation begins, so wait for the ball to come back to about the same point where you just dropped it, then pause.
- raise the lower pendulum up and to the left, across the anchor point from the first pendulum. Looks like its height relative to the the other pendulum is irrelevant.
- Let go, watch as the simulated pendulums speed up over time, seemingly violating conservation of energy/momentum, until they reach a speed the simulation can no longer handle and the pendulum becomes just a line that extends outside the screen space. This also seemed to break the rendering of the pause button, for some reason (although I could still click it to pause afterwards).
Update: actually it looks like the line was just a coincidence the first time. After reproducing, I found that the pendulum lines appeared in three separate places, two of which don't seem possible:
oh, actually, four places. It's up behind the pause button too.
Thanks for letting me know, appreciate it, I will see what's the issue
The non-conservation of energy is probably due to the fact that you're using Euler integration.
You can get rid of this behavior by using a symplectic integrator, such as the Verlet method (look specifically at the "Velocity Verlet" section). Symplectic integrators approximately conserve energy, and are generally more stable.
@gregreen oh okay, thanks, will check out
Sorry, one would think that a guy with degrees in both physics and compsci should be well-equipped to diagnose this, but it turns out that I don't remember anything they taught me in Intermediate Mechanics - a class where I literally had to build a double-pendulum simulation.