News for hackers. Stuff that matters.
Re:Interactive Double Pendulum Playground by Evidlo on Wednesday October 08, 2025 @02:56AM (#45512953)
Anyone else feel like the pendulum motion seems off? Maybe the default mass settings are weird, but the movement just does not look physical to me.
Re:Interactive Double Pendulum Playground by navtoj on Wednesday October 08, 2025 @03:17AM (#45513075)
There's a "How To Use?" section on the GitHub repo page.

https://github.com/theabbie/DoublePendulum?tab=readme-ov-fil...

Re:Interactive Double Pendulum Playground by WithinReason on Wednesday October 08, 2025 @03:19AM (#45513084)
Yes I think the physics is wrong
Re:Interactive Double Pendulum Playground by kookybakker on Wednesday October 08, 2025 @04:00AM (#45513362)
When you bring up the lower mass and let it go, it seems to push the upper mass away, which should never happen. This whole site smells off vibe coded jank.
Re:Interactive Double Pendulum Playground by probabletrain on Wednesday October 08, 2025 @06:01AM (#45514251)
> This whole site smells off vibe coded jank.

A vibe-coded double pendulum sim should produce a much better result than the physics on this page. Claude Code made this just now off one prompt, the physics are much better: https://keir.is/swinging

Re:Interactive Double Pendulum Playground by Evidlo on Wednesday October 08, 2025 @02:12PM (#45518984)
I don't think that's fair. Also the project is 4 years old so the timeline doesn't really work out for being vibe-coded.
Re:Interactive Double Pendulum Playground by mihau on Wednesday October 08, 2025 @04:19AM (#45513483)
Yep, it's just bad. Physics feels totally off.
Re:Interactive Double Pendulum Playground by magicalhippo on Wednesday October 08, 2025 @05:48AM (#45514149)
It's way off. My first guess was that there was something wrong with the physics code, but after carefully checking against this[1] derivation of the Hamiltonian it seemed fine, and once I wrapped my head around the JavaScript the RK4 integration[2] checked out as well.

So, what else might be wrong I wondered. Well, it seems to move in the wrong direction... so I checked how the pendulum is displayed. And sure enough, I think there's a sign error:

  getUpperBob() {
     const { x0, y0, ang0, l0 } = this;
     const { x, y } = this.calculateBobPosition(x0, y0, ang0, l0);
     return { x, y };
   }

   getLowerBob() {
     const upperBobPos = this.getUpperBob();
     const { ang1, l1 } = this;
     const { x, y } = this.calculateBobPosition(
    upperBobPos.x,
    upperBobPos.y,
    -ang1,
    l1
     );
     return { x, y };
   }
Note how the upper bob uses ang0 while the lower one has -ang1. Meanwhile the physics derivation assumes both angles are against the vertical, so have same sign.

Changing -ang1 to ang1 does indeed make the pendulum move in a natural way, except now dragging it is flipped. Ie you drag it left and it moves right. Another sign error in setLowerBobPos. Fixing that as well it now works as I'd expect.

[1]: https://dassencio.org/46

[2]: https://lpsa.swarthmore.edu/NumInt/NumIntFourth.html##sectio...

Re:Interactive Double Pendulum Playground by Evidlo on Wednesday October 08, 2025 @02:10PM (#45518965)
Just made a PR
Re:Interactive Double Pendulum Playground by magicalhippo on Thursday October 09, 2025 @02:17AM (#45524146)
I considered it, but had to go to work and I figured since the last commit was over 4 years ago it might just sit there idly, so I skipped it.

But no, PR was merged in short order. Lesson learned.

Re:Interactive Double Pendulum Playground by cabirum on Friday October 10, 2025 @06:20AM (#45537196)
Hn shows this story is 3 hours old, yet your GitHub PR was made 2 days ago, linking here?
Re:Interactive Double Pendulum Playground by pansa2 on Friday October 10, 2025 @08:21AM (#45538147)
The story has been reposted to HN via the “second-chance pool”, which resets the dates.

https://news.ycombinator.com/item?id=26998308