Original Post
I'M doing colision detection with ellipsoids (in 2d), it works, but now I want the ship to bounce of the asteroids in the respective angle. The code below works in about 80% of the cases, in the other cases the ship flies through the asteroid in odd angles. Because the asteroids are round, no ellipsoids are nessecary. So can anyone find the problem?
//factor is pi/180
float t1 = (float)acos ( DotProduct(player.origin, asteroid[m].origin) / (Magnitude(asteroid[m].origin) * Magnitude(player.origin)) );
if(player.rotation.z<=-360.0f) player.rotation.z += 360.0f;
if(player.rotation.z>= 360.0f) player.rotation.z -= 360.0f;
float t2 = (player.rotation.z-180.0f) * factor, t3 = 0.0f;
if(t1>=t2) t3 = t1+(t1-t2);
else t3 = t2+(t2-t1);
player.rotation.z = t3 / factor;
THX!
Edited by - NoNseNse on 10/21/00 6:07:17 PM