Archived

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

Really fast circle - square collision detection?

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

Recommended Posts

This thread led to this question How would I do it? I know how to do it first getting a line from the squares center to the circles center, getting the angle from that checking the point on the circles perfieri. But what is the most optimized way to do it? /MindWipe

Share on other sites
No?? Please anyone? Or can someone point me to a good tutorial? Yes, I''ve tried google.

/MindWipe

Share on other sites
Usually when optimising collision routines, the best methods are to check when it''s NOT colliding.

Simple bounding box checks against the sphere and square would speed things up considerably.

Share on other sites
quote:
Original post by Damocles
Usually when optimising collision routines, the best methods are to check when it''s NOT colliding.

Simple bounding box checks against the sphere and square would speed things up considerably.

Or even circle/circle testing; the distance from one corner of the square to the center is the radius of its bounding circle (because it''s a square).

Depends on which of the two is larger.

Superpig
- saving pigs from untimely fates, and when he''s not doing that, runs The Binary Refinery.
Enginuity1 | Enginuity2 | Enginuity3 | Enginuity4

Share on other sites
Nobody''s got an easy sollution?

/MindWipe

Share on other sites
Square->square checking might be the best way.

Square side length=s
d=r+s/2

if circlex<squarex-d then missed
if circlex>squarex+d then missed
if circley<squarey-d then missed
if circley>squarey+d then missed

I hope I got that right. The corners will not be perfect but it should be fine for a game I think.

Mark
Cornutopia Games
http://www.cornutopia.net

[edited by - Mark Sheeky on August 17, 2003 6:27:28 AM]

Share on other sites
quote:
Original post by Mark Sheeky
Square->square checking might be the best way.

Square side length=s
d=r+s/2

if circlexif circlex>squarex+d then missed
if circleyif circley>squarey+d then missed

I hope I got that right. The corners will not be perfect but it should be fine for a game I think.

Mark
Cornutopia Games
http://www.cornutopia.net

[edited by - Mark Sheeky on August 17, 2003 6:27:28 AM]

I think there''s something to that. Gotta work on that and try to come up with a great system, because I need the player (circle) to slide against the walls if too near (the squares).

/MindWipe

Share on other sites
http://www.gamasutra.com/features/19991018/Gomez_4.htm

My Site

Share on other sites
I think the main problem with circle/square crash detection is accuracy. I''ve been trying to come up with a way to check line-segment/circle crashes, but my solutions either a) produce VERY erronious results or b) involve calculus, which is incredibly slow and hard to think about. It''s relatively easy to tell if a circle is crossing a LINE (that is, unlimited length) by throwing down some coordinate transformations (getting the circles coordinates if the line is treated as the y-axis), but these methods can result in false-positives if it is a line SEGMENT. Sorry I couldn''t be more help, but if anyone knows how to do this, then box/circle crashes would be easy.

Share on other sites
Idea:

To improve the accuracy of my idea you only need to see if the circle is in one corner and at that point to a circle->circle detection using the corner of the square and the radii of the circle.

Imagine the square is the middle box of a noughts and crosses (that is tic-tac-toe). If the circle lies in one of the 4 oblique boxes, treat it like a square as in my previous post.

If the circle is in one of 4 the diagonal boxes, treat it like a circle to circle test with the corner of the central square.

Mark
Cornutopia Games
http://www.cornutopia.net

1. 1
Rutin
55
2. 2
3. 3
4. 4
5. 5

• 10
• 28
• 20
• 9
• 20
• Forum Statistics

• Total Topics
633412
• Total Posts
3011737
• Who's Online (See full list)

There are no registered users currently online

×