NM found an algorithm at NEHE lesson 30
/**
* Bounce Strategy found at NEHE
* http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=30
* Does not take mass into acccount
* In More Detail:
*
* a) Find X_Axis
*
* X_Axis = (center2 - center1);
* Unify X_Axis, X_Axis.unit();
*
* b) Find Projections
*
* U1x= X_Axis * (X_Axis dot U1)
* U1y= U1 - U1x
* U2x =-X_Axis * (-X_Axis dot U2)
* U2y =U2 - U2x
*
* c) Find New Velocities
*
* (U1x * M1)+(U2x*M2)-(U1x-U2x)*M2
* V1x= --------------------------------
* M1+M2
* (U1x * M1)+(U2x*M2)-(U2x-U1x)*M1
* V2x= --------------------------------
* M1+M2
*
* In our application we set the M1=M2=1, so the equations get even simpler.
*
* d) Find The Final Velocities
*
* V1y=U1y
* V2y=U2y
* V1=V1x+V1y
* V2=V2x+V2y
*
* The derivation of that equations has a lot of work, but once they are in a form like the above they can be used quite easily. The code which does the actual collision response is:
*/
public void calcbounce(FlightIntersector A, FlightIntersector B) {
Vector3 pb1,pb2,xaxis,U1x,U1y,U2x,U2y,V1x,V1y,V2x,V2y;
float a,b;
pb1=A.get_boundingSphere().get_center(); // Find Position Of Ball1
pb2=B.get_boundingSphere().get_center(); // Find Position Of Ball2
xaxis = Vector3.subtract(pb2,pb1,null); // Find X-Axis
xaxis.normalize();
a = Vector3.dot(xaxis,A.get_velocity()); // Find Projection
U1x=xaxis.multiplythis(a,null); // Find Projected Vectors
U1y=Vector3.subtract(pb1,U1x,null);
xaxis=Vector3.subtract(pb1,pb2,null); // Do The Same As Above
xaxis.normalize();
b=Vector3.dot(xaxis,pb2); // To Find Projection
U2x=xaxis.multiplythis(b,null); // Vectors For The Other Ball
U2y=Vector3.subtract(pb2,U2x,null);
//(U1x+U2x-(U1x-U2x))*0.5;
V1x=Vector3.multiply(0.5f,Vector3.subtract(Vector3.add(U1x,U2x,null),Vector3.subtract(U1x,U2x,null),null));// Now Find New Velocities
//V2x=(U1x+U2x-(U2x-U1x))*0.5;
V2x=Vector3.multiply(0.5f,Vector3.subtract(Vector3.add(U1x,U2x,null),Vector3.subtract(U2x,U1x,null),null));
V1y=U1y;
V2y=U2y;
A.set_velocity(Vector3.add(V1x,V1y,null));
B.set_velocity(Vector3.add(V2x,V2y,null));
}
}