# Circular Hit Boxes Math Question

This topic is 3000 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Say I have two objects and I want to create circular hitboxes. I have the center of each point and a radius: point1 (x1 ,y1, r1); point2 (x2, y2, r2). I am using a 2D coordinate system where upper left is 0,0, x increases to the right, y increases to the bottom. How do I test for collision between these circles?

##### Share on other sites
Upon further reflection, this has a simple answer. Test the distances between the centers! Duh. If at any point the distance of between (x1, y1) and (x2, y2) is <= r1+r2, then I've got a collision.

Duh.

Sorry.

##### Share on other sites
'Circular hitboxes', huh? Hehe... :-)

Anyway, testing for intersection between two circles is super-easy. If the distance between the centers of the circles is less than the sum of their radii, there is an intersection. (In practice, squared distances are usually compared for the sake of efficiency.)

You can also easily derive other collision data (minimum translational vector, collision point and normal, etc.) from this info if needed.

The continuous version of the test is also pretty straightforward (it basically reduces to a segment-circle intersection test).

[Oops, too late!]

1. 1
Rutin
19
2. 2
3. 3
JoeJ
16
4. 4
5. 5

• 26
• 20
• 13
• 13
• 17
• ### Forum Statistics

• Total Topics
631700
• Total Posts
3001781
×