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[0] - position[0];

double dy = ball.position[1] - position[1];

double dz = ball.position[2] - position[2];

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

double dt;

double vp1 = (velocity[0]*(dx/d)) + (velocity[1]*(dy/d)) + (velocity[2]*(dz/d));

double vp2 = (ball.velocity[0]*(dx/d)) + (ball.velocity[1]*(dy/d)) + (ball.velocity[2]*(dz/d));

if(r1 + r2 < d){

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

position[0] -= velocity[0]*dt;

position[1] -= velocity[1]*dt;

position[2] -= velocity[2]*dt;

ball.position[0] -= ball.velocity[0]*dt;

ball.position[1] -= ball.velocity[1]*dt;

ball.position[2] -= ball.velocity[2]*dt;

}

[/code]