   [Java]Collision of 2D Circles, and the angle at which they hit
  I am coding a game as a final project for my AP Computer Science class, and I know that you can determine whether two circles are touching based on the fact that their distance is equal to or less than the sum of each of their radii, but how can I tell the angle at which they collide? One is a stationary semi-circle, and the other is a ball that is being "bounced" from side to side of the applet. I need to take into account the pre-collision direction of the ball and use it to calculate the new trajectory of the ball.Also, while on the subject of Physics, should all of these collisions be assumed to be perfectly elastic?[Edited by - cmanning1200 on May 7, 2009 10:40:09 PM]
  I can partly answer your problem, maybe someone else will come in with a full answer.I will presume you mean 2D as you said circles.You basically use trig...A = angle between points:Tan A = X2-X1/Y2-Y1ORA = Tan(inverse) * X2-X1/Y2-Y1I dont think this will work for all four quadrants, on the engine I was using it had a Tanfull function which is what you need, this should get you part of the way.I have an example of some of the physics behind 2D collisions with circles but I recently wiped my hard-drive, so it is backed up on a disk somewhere, let me know if you want to see them.When I did it, all my collisions were elastic, I think thats the best way to start, then if you want to remove energy from the system it shouldn't be too hard to do.;  You can use Math.atan2 to calculate the angles between the balls (bounce normal) and the angle of the ball direction. You then subtract and add these together to get outgoing direction.But! your probably better off to mirror the ball direction using vectors instead: http://www.gamedev.net/community/forums/topic.asp?topic_id=411626   ;  thanks! i appreciate the help, both of you.   