Sign in to follow this  

Circle rectangle collision

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

I'm trying to determine if a 2D circle is intersecting with a 2D rectangle. Is this simple as finding the distance between the center of the circle and the center of the rectangle and checking if that distance is less than the diameter of the circle?

Share this post


Link to post
Share on other sites
Quote:
Is this simple as finding the distance between the center of the circle and the center of the rectangle and checking if that distance is less than the diameter of the circle?
That won't work for a circle and a box, no. (What you describe is how you would test for intersection between two circles or spheres.)

One way to test for intersection between a circle (or sphere) and a box is to find the point on the box closest to the circle/sphere center, and then compare the distance (or squared distance) from this point to the circle/sphere center to the circle/sphere's radius (or squared radius).

Share this post


Link to post
Share on other sites

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