#### Archived

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

# How do you do Collison detection in a cricle rather then rectangle

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

## Recommended Posts

i was wondering how do you test for collision if your object is a circle and you dont want to test for a rectangle but rather a circle ? I never have done anything with circles or polygons so could someone show an example?

##### Share on other sites
Circle collision is much easier than rectangle collision. The test for this looks like this:

If SQRT((Circle1.X, Circle1.Y) ^ 2 + (Circle2.X, Circle2.Y)^ 2) <= Circle1.Radius + Circle2.Radius Then
''Collision Detected
Else
''No Collision
End If

That''s how simple it is. I basically test the distance between both center points of the circles, Then it checks if that distance is less then the combined radius of the two circles. If the distance is les then there has been a collision.

That''s it

Horny Farmer (Jolly Rancher)

##### Share on other sites
something to note here is that the sqrt is slow.

im not sure, but would this be faster?

if (a^2+b^2)<(r1+r2)^2 then {} else {}

##### Share on other sites
hello

quote:

im not sure, but would this be faster?

yes.

goodbye

MY HQ

1. 1
2. 2
3. 3
Rutin
13
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633700
• Total Posts
3013419
×