Sign in to follow this  

Normal of circle intersection point

This topic is 2040 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
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

This topic is 2040 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this