Sign in to follow this  

Circle Collision detection

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

Hello, I am trying to figure out collision detection with a circle. I found out the formula for getting distance between two points. The way is very basic and it only happens if the two points are exactly on each other. How would I go about checking all the points of the circle? I think that checking all the points would be a waste of processor time. Is there another way I could detect if one point on one circle is in another circle, or rectanlge or triangle?

Share this post


Link to post
Share on other sites
Circle-Circle Intersection on Mathworld - It should explain how to.

It's very easy actually, you first find the distance between the two centerpoints.
dy = y' - y //dif y-axis
dx = x' - x //dif x-axis
dist2 = dx*dx + dy*dy //Pythagoras algorithm



You now have the distance squared, but that doesn't matter. For speed you just square the radii also.
sumr = r + r' //allowed distance (radius + radius')
if(dist2 < sumr*sumr) collision = true

Share this post


Link to post
Share on other sites
(Finite) Line-Circle Intersection is a topic I posted to ask how it could be implemented.
As you can read in the last reply, I confirmed jyk's method was working, so that's the first step of having Circle-Rectangle/Triangle collision. The obvious next step would be using that (Finite) Line-formula for each of the edges in those primitives. Repeat 4 time for Rectangles, and 3 times for Triangles.

Perhaps there is a faster way, but this sure works for me.

Share this post


Link to post
Share on other sites

This topic is 4588 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this