#### Archived

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.

## 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 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)

1. 1
2. 2
Rutin
18
3. 3
4. 4
5. 5

• 14
• 12
• 9
• 12
• 37
• ### Forum Statistics

• Total Topics
631431
• Total Posts
3000039
×