Hacker News new | ask | show | jobs
by flannelhead 4360 days ago
Very nice simulation you've got there! I also did a triple pendulum in JS a while ago. Quite a lot more than 100 lines of code, though. The equations of motion alone take up lots and again lots of space. (Imagine typing them in! I don't even dare to think about adding a fourth degree of freedom) http://users.jyu.fi/~samakapa/triplependulum/

My dynamics course teacher actually showed that the double pendulum can be linearized by some approximations (throwing out some negligible terms, small angle approximations etc.), and that way two modes of oscillation could be found: antisymmetric and symmetric oscillation. Just try with small initial angles with OP's script and you'll see.

1 comments

... that pendulum doesn't mirror reality at all. It's as though the first mass is constantly being accelerated by something other than gravity.
First mass counting from which end? The masses are accelerated by each other as there are rigid rods between them.

The lack of friction and the perfectly rigid coupling between the joints might be what makes it seem lacking reality. If we'd extend the chain with more links, the motion of the outermost mass would become more and more unpredictable due to extreme acceleration.

Of course I might have made a mistake somewhere, but I checked that energy is conserved between the frames of the animation (excluding minor energy drift due to the numerical integration).