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

Started by
2 comments, last by DevLiquidKnight 21 years, 8 months ago
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?
Advertisement
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)
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 {}

die or be died...i think
hello

quote:
im not sure, but would this be faster?


yes.

goodbye

MY HQ
[size=2]aliak.net

This topic is closed to new replies.

Advertisement