0

I realize this question has been answered before, but not yet in terms I understand.

In code I'm bouncing two balls off each other. I know each ball's current direction in radians, and I can find the normal angle using the atan2() function.

Say I ignore one ball and focus on the other - I have an angle of incidence, and a normal angle. Is there a straightforward way to find the angle of reflection without needing magnitudes?

user6191359
  • 69
  • 1
  • 9
  • Possible duplicate of [Ball to Ball Collision - Detection and Handling](http://stackoverflow.com/questions/345838/ball-to-ball-collision-detection-and-handling) – cmourglia Feb 01 '17 at 10:10
  • no, there isn't, because trajectories intersect in no way actually tells you whether there _is_ a collision in the future. If the balls are 100 units apart, and one is traveling at 100 units per second, and the other at anything less than that, we're pretty much guaranteed they'll just pass each other by instead of colliding. You need to find the intersection of actual vectors, not just angles. – Mike 'Pomax' Kamermans Jan 01 '23 at 19:09

1 Answers1

0

This isn't necessarily possible. A collision is determined by the conservation momentum and energy before/after impact, but the result differs on the type of collision (elastic/inelastic). As the equations take into account both of the balls velocity and mass before the collision, it is not possible to look at them independently and expect a correct result.

The only case that is "easy", is if the other ball is a wall and the collision (this is because the wall doesn't move—it's mass is 'infinite' and the momentum will be 0 before and after collision). Then the output angle is directly opposite the incident.

pingul
  • 3,351
  • 3
  • 25
  • 43
  • So in a world with no friction or elasticity - the question remains, can I find the incident, which should be directly opposite, with only degrees incoming and a normal? I understand you're saying it won't produce *realistic* physics, but that's not my question - I'm just asking geometry – user6191359 Feb 01 '17 at 15:13
  • @user6191359 Friction/elasticity does not matter--what matters is that you have two moving objects (instead of the case with one wall, it is not moving). For the wall case (2D), imagine it has the normal 180˚ (that is, directly to the left). A ball coming from left and below would maybe have an angle 200˚, it would be reflected to 160˚ (that is, the difference in angle was +20˚ so afterwards it is -20˚). In general I would recommend against this, and use normal vector algebra instead. – pingul Feb 01 '17 at 15:59
  • @user6191359 I realize the example above is a little weird. All the angles are taken _from the perspective of the wall_. The incident ball would in its own frame of reference, in this case, have an angle of +20˚. I hope anything of this makes sense. – pingul Feb 01 '17 at 16:11
  • I do understand your concern. I looked into the duplicate question and will probably use vector algebra. That still doesn't help me though, my original question was how, not if it is a good approach – user6191359 Feb 01 '17 at 16:17
  • @user6191359 Yes, understood. Maybe I didn't make it clear enough in the post. There is not way to do what you want in a 'physical sense', so the answer to your question is "no, it is not possible to do what you want". – pingul Feb 02 '17 at 12:54