Jump to content
  • Advertisement
Sign in to follow this  
dabo

Normal of circle intersection point

This topic is 2285 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I am creating a simple hockey game and I am trying to figure out how to handle puck collisions with the boards. It is pretty easy with the short and long sides since each one have only one normal but I have problems with the rounded corners, each will have lots of normals.I don't know how to calculate the normal of the intersection point between the puck and the corner. How does one usually go about doing this? I appreciate any help. I do 2d line intersection tests for the short and long sides and it works well, is it possible to do something similar between a line and a circle? And then from the intersection point calculate the normal in that point?

Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Say the line segment is (x1,y1)-(x2,y2) then it can be represented parametrically as
x(t) = x1*t + (1-t)*x2
y(t) = y1*t + (1-t)*y2
each corner is the arc of a circle, let the corner circle we want to test be
(x - cx)^2 + (y - cy)^2 = r^2
where the circle has center (cx,cy) and radius r.
Plug x(t) and y(t) into the circle's equation and solve for t. Since it's quadratic you'll get two answers. Any solution where 0 <= t <= 1 is an intersection of the line segment and the circle. Use additional logic to determine if the intersection occurs in the arc of the circle that is the corner of the board.
x(t) and y(t) for a valid sloution is the point of intersection, call it (x0,y0). The normal of the circle you want then is (x0,y0)-(cx,cy) i.e. the puck should reflect relative to this line. Edited by jwezorek

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!