# Vector to circle collision

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

## Recommended Posts

How do i find if and where a vector intersects a circle of X radius in the cartesian plane?

##### Share on other sites
It's probably faster just to explain it than to find a reference for you. So...

By vector I assume you mean linear component of some sort (line, ray, or segment). Let the line be O+tD. The squared distance from the line to the circle center at parametric value t is:

f(t) = (O+tD-C)2

Let d = O-C, and multiply to get:

f(t) = (D.D)t2+2(d.D)t+(d.d)

You're interested in the values of t at which the squared distance from the line to the circle center is exactly r2. Set f(t) to this value and you get a quadratic, the solution of which tells you if and where the line and circle intersect. For rays or segments, just reject values of t outside the acceptable range.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 12
• 15
• 14
• 46
• 22
• ### Forum Statistics

• Total Topics
634055
• Total Posts
3015276
×