Bead on a Wire

Use the arrow keys to apply a world-x,y force to the bead.
Press [f] and [g] to toggle friction and gravity, respectively.
You may need to click on the canvas to receive input.
With friction and gravity on, see if you can get a max speed > 15 !

The constraint is satisfied automatically by using the wire arclength parameter q.
The generalized coordinate q is integrated naively (semi-implicit Euler).
The generalized forces on the bead include gravity, friction, and user input.
Hit the "Source" button to change the curve or run your own version of the code.
Any changes will be reset upon page refresh.

Source