Bead on a Wire

This is an implementation of a simple bead on a wire system. The bead is constrained by a parametric constraint representation. The bead is constrained to the unit circle in the X Y plane. Gravity is initially the only external force acting on the bead. A friction force may be added to the simulation. The bead starts at (1,0) with a mass of 1kg. While the mass parameter can be adjusted, it does so for all beads in the scene. All of these parameters may be altered.

The solver is set to Midpoint on startup and can be changed to Euler and RK4. Midpoint provides enough stability for most simulations. The beads are tessellated with 40 polygons each.


Movie


Also, for more interesting effects, multiple beads may be added to the system. These beads will collide and interact with one another. Upon collision, the beads swap velocities in a perfectly elastic collision. As beads are added to the system, they will assume a random non-colliding position on the wire and a unique color.


Movie


Code

The code and binaries for OS X are available here.
Most of the Bead on a Wire code is in simulation/bead.cpp.

The text along the bottom controls the simulation. Lowercase items are activated by placing the cursor over them and using the scroll-wheel. The uppercase items can be clicked on. The ~ or ` key brings up the console display.

contact info on the about me page