Jump to content
  • Advertisement
Sign in to follow this  
Kustaz

Vector to circle collision

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

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

Share this post


Link to post
Share on other sites
Advertisement
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.

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!