Physically-Based Modeling

Homework 3

Code
Home

Basic Application

A screen shot of bead on a wire.

A screen shot of the controller for bead on a wire

This is my implementation for Bead on a wire for homework 3. I decided to have a little fun with this assignment and implament two beads on separate wires. One bead is traveling on the y,z plane and the other is traveling on the y,z plan. When the beads collide, the velocity from the beads are swapped. This behavior can be turned off by unchecking the allow collision box. Other options which can be changed about the simulation are the initial position (in degrees), bead mass, and initial velocity (tangent to the initial position). In addition, the time step, and spring k (of damp spring) can be played with. For collision detection, I use the simple and easy distance check between the two spheres.


One small note, this is somewhere in the assignment. I think it may be the best line of code I have ever written...

    for (float i=0,a=0,h=50 ; i < h ; a=radius*sin((++i) * 2 * M_PI / h)) 
        glVertex3f((w==0)?a:0, radius*cos(i * 2 * M_PI / h), (w==1)?a:0);