Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Circle - point collision detection formula?

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

Hi all, I''m trying to write a game wherein I want to do what seems to be a simple collision detection. I have a circle moving at a constant rate, and a point moving at a constant rate. I want to determine whether the circle collides with the point. I have looked around for a long time on the ''net for a formula to do this detection, but have not found one. I would appreciate greatly any pointers to such. Thanks, -Ken Stuart kstuart@ucla.edu PS. I am writing in Perl, in case there''s already some code available that I could just import.

Share this post

Link to post
Share on other sites
You''re in luck; point-in-circle is probably the easiest kind of collision detection you can possibly do.

If the distance between the center of the circle and the point is less than the radius of the circle, the two have collided.
If they are equal, the point is on the circle itself.
Otherwise, there was no collision.

Now, determining the distance between the points can be slow because of the sqrt call in determining the distance between the two points. However you can eliminate the sqrt call by comparing the distance squared with the radius squared. One extra multiplication is a whole lot faster than a sqrt .

-RWarden (roberte@maui.net)

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!