Reflecting a circle off another circle

  • Thread starter Thread starter jrs8719
  • Start date Start date
  • Tags Tags
    Circle
Click For Summary
SUMMARY

The discussion focuses on calculating the reflection of a ball off a circular object in a computer game using geometric principles. The key variables include the ball's current and end coordinates, the circle's center, and the intersection point of the ball's path with the circle. The solution involves determining the angle of incidence and reflection using vector mathematics, specifically the orthogonal projection of the incoming vector onto the circle's radius. The final reflection point coordinates are derived using the formulas: x1 = (x0(a^2-b^2) + 2aby0) / (a^2 + b^2) and y1 = (y0(b^2-a^2) + 2abx0) / (a^2 + b^2).

PREREQUISITES
  • Understanding of vector mathematics and projections
  • Knowledge of geometric reflection principles
  • Familiarity with coordinate systems in 2D space
  • Basic programming skills for implementing the solution in a game engine
NEXT STEPS
  • Study vector projection techniques in 2D geometry
  • Learn about collision detection algorithms in game development
  • Explore physics engines like Box2D for handling reflections
  • Research the implementation of ray-casting for accurate intersection calculations
USEFUL FOR

Game developers, physics programmers, and anyone involved in implementing realistic object interactions in 2D gaming environments.

jrs8719
Messages
1
Reaction score
0

Homework Statement



I am working on a computer game and I need to correctly reflect a ball off a circle object. I am trying to do it as a line and circle intersection. I know the intersect point of the line (ball path) and the circle. Now I want to rotate the ending point of the ball path about the intersection point to get the correct angle of reflection. The following are known:

ball current x
ball current y
ball end x
ball end y
ball radius

circle center x
circle center y
circle radius

intersection point of ball path and circle x and y

Homework Equations



I don't know.

The Attempt at a Solution



I know I need to find the angle of incidence between the tangent line and the incoming ball path which will also equal my angle of reflection. I think once I know those two angles I can subtract them from 180 to get my rotation angle then rotate my end point about the angle of intersection by that amount. I just don't know how.

I have attached a pic. Again, I know the two end points of my line segment, the point of intersection and the radius of the circle.

I am ultimately trying to get the point marked by the open circle, so I need to know the angle between the ball path and the norm, which is the blue line.

Thanks.
 

Attachments

  • Untitled.jpg
    Untitled.jpg
    2.8 KB · Views: 504
Physics news on Phys.org
Call the starting position of the ball (x0,y0), the bounce point on the circle (a,b), and the end point (x1,y1). The vector from the (a,b) to (x0,y0) is

\vec V = \langle x_0 - a, y_0 - b\rangle

The position vector of (a,b) is

\vec R = \langle a,b\rangle

and a vector of length one in that direction is

\hat r = \frac{\vec R}{| \vec R|}

The orthogonal projection of V on the radius direction is

\vec V_{perp} = \vec V - (\vec V \cdot \hat r)\hat r

Then the ending point is:

\langle x_1,y_1\rangle = \vec R + \vec V - 2\vec V_{perp}
 
Since this apparently isn't homework, I will save you a little more work. Here's the coordinates (x1,y1) of the reflection point in terms of the given point and the bounce point on the circle:

x_1=\frac{x_0(a^2-b^2)+2aby_0}{a^2+b^2}

x_2=\frac{y_0(b^2-a^2)+2abx_0}{a^2+b^2}
 

Similar threads

  • · Replies 14 ·
Replies
14
Views
1K
Replies
8
Views
3K
Replies
5
Views
3K
Replies
19
Views
3K
Replies
20
Views
4K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 48 ·
2
Replies
48
Views
6K
  • · Replies 16 ·
Replies
16
Views
2K