Hello Professor Hwang,

You might have guessed my name, it's Manav. In my class we have been creating a class to emulate the physics aspect for a bouncing ball in C++ and using the glut class from OpenGL to show the ball. So far in our class we have many balls that can bounce and slow down due to gravity. I wanted to do more since I am a little bored and so I've been trying to mold your 2D collision of balls for my 3D collision for my balls. Since I registered with the forum just now (which by the way was very helpful for me to get started) I am having troubles. I am stuck at trying to do the part where you calculated the projection velocities, since I have to deal with 3 dimensional vectors. Help would be greatly appreciated. The following is the code for my collision procedure in my C++ class:

[code]void BallObject::Collision(BallObject ball){
double r1 = diameter / 2; //first ball's radius
double r2 = ball.diameter / 2; //second ball' radius

double dx = ball.position - position;
double dy = ball.position - position;
double dz = ball.position - position;

double d = sqrt((dx*dx) + (dy*dy) + (dz*dz));
double dt;

double vp1 = (velocity*(dx/d)) + (velocity*(dy/d)) + (velocity*(dz/d));
double vp2 = (ball.velocity*(dx/d)) + (ball.velocity*(dy/d)) + (ball.velocity*(dz/d));

if(r1 + r2 < d){
dt =(r1+r2-d)/(vp1+vp2);

position -= velocity*dt;
position -= velocity*dt;
position -= velocity*dt;

ball.position -= ball.velocity*dt;
ball.position -= ball.velocity*dt;
ball.position -= ball.velocity*dt;
}
[/code]