Colisión esfera - esfera
http://sabia.tic.udc.es/gc/Contenidos%20adicionales/trabajos/Opengl/tut_opengl/colisiones.htm
/************************************************************************************/
/*** Find if any of the current balls ***/
/*** intersect with each other in the current timestep ***/
/*** Returns the index of the 2 intersecting balls, the point ***/
/*** and time of intersection ***/
/************************************************************************************/
int FindBallCol(TVector& point, double& TimePoint, double Time2,
int& BallNr1, int& BallNr2)
{
TVector RelativeV;
TRay rays;
double MyTime=0.0, Add=Time2/150.0, Timedummy=10000, Timedummy2=-1;
TVector posi;
// Test All Balls Against Eachother In 150 Small Steps
for (int i=0;i 40) continue;
// If Distance Between Centers Greater Than 2*radius
// An Intersection Occurred
while (MyTime(MyTime-Add)) Timedummy=MyTime-Add;
BallNr1=i;
BallNr2=j;
break;
}
}
}
}
if (Timedummy!=10000)
{
TimePoint=Timedummy;
return 1;
}
return 0;
}







