Brian Glatt
Brian Glatt

Reputation: 21

Calculate Point collision between a point of a given vector and the edge of a Circle

Lets say I have a point within a circle(not necessarily the origin) moving at a given vector how would I calculate the x and y coordinate of the point where it hits the edge of the circle.

Upvotes: 0

Views: 631

Answers (1)

MBo
MBo

Reputation: 80187

Shift all coordinates by -cx, -cy. Now circle is centered at origin and has equation

x^2+y^2=R^2

Point coordinate (px, py), unit direction vector is (dx,dy). Equation of ray:

x = px + t * dx
y = py + t * dy

Substitute these variables into the circle equation, solve equation, find parameter t>0, then find intersection point (x,y), shift it back by (cx, cy).

Upvotes: 1

Related Questions