Reflection of a circle from another circle

Work with iPhone and Objective C.

I am working on a game and I need to properly reflect the ball from the circle object. I try to do this as the intersection of a line and a circle. I have a ball position outside the circle, and I have a new ball position that will be inside the circle the next time the draw is updated. I know the intersection point of the line (ball trajectory) and the circle. Now I want to rotate the end point of the ball path relative to the intersection point to get the correct angle of reflection from the tangent.

The following is known:

  • ball current x, y
  • ball end x, y
  • ball radius
  • circle center x, y
  • circle radius
  • the intersection point of the ball path and the circle x and y

I know that I need to find the angle of incidence between the tangent line and the incoming ball, which will also be equal to my angle of reflection. I think, as soon as I recognize these two angles, I can subtract them from 180 to get my rotation angle, and then rotate the end point around the intersection angle by this amount. I just don’t know how.

+3
source share
2 answers

First, you should note that the center of the ball should not be inside the circle to indicate that there is a reflection or rebound. As long as the distance between the center of the ball and the circle is less than the radius of the ball, there will be a rebound.

R, r, , , R + r, 0. / .

() , N ( ).

V V -2 (N & sdot; V) N, ( N & sdot; V) . V .

, , , " ". V N. Mathworld , , , .

+3

.
:
r1 = >
r2 = >

, .
r1 + r2, .

. python, , , . , Objective C. PeterCollingRidge.

0

Source: https://habr.com/ru/post/1752738/


All Articles