Separating Axis Collision Detection
Hi,
I've been trying to write a simple separating axis collision detection function between two polygons in C and I can't find any working example code. I don't really care what language it's in, as long as I can run it on my mac and can then port it to C. I'm also simultaneously working on the same thing in Processing, just for testing purposes. You can view the Processing Java Applet here: http://magneon.ath.cx/Test (source file linked from the page) to see what my problem is (the collision is just a little bit off on one side). If anyone has any links or example code lying around I would greatly appreciate it.
I've been trying to write a simple separating axis collision detection function between two polygons in C and I can't find any working example code. I don't really care what language it's in, as long as I can run it on my mac and can then port it to C. I'm also simultaneously working on the same thing in Processing, just for testing purposes. You can view the Processing Java Applet here: http://magneon.ath.cx/Test (source file linked from the page) to see what my problem is (the collision is just a little bit off on one side). If anyone has any links or example code lying around I would greatly appreciate it.
Skorche Wrote:http://www.harveycartel.org/metanet/tuto...rialA.htmlThanks, but that's what I wrote the existing (non-working) code from. I'm kind of looking for a working example so I can see what's wrong with my implementation.
The logical steps are quite simple. You must create a min and max vector of each polygon, and then you check on each x,y, and z that the intervals (don't) overlap. That's the interval test in words.
The intervals don't intersect if (minA >= maxB) || (minB >= maxA). The common range is from max(minA, minB) to min(maxA, maxB). Hope that makes sense. The code for this is real simple, I can post some if you can't figure it out.
The intervals don't intersect if (minA >= maxB) || (minB >= maxA). The common range is from max(minA, minB) to min(maxA, maxB). Hope that makes sense. The code for this is real simple, I can post some if you can't figure it out.
"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Optimize the collision detection | alaslipknot | 1 | 308 |
May 12, 2013 08:02 PM Last Post: SethWillits |
|
| Collision detection tutorial | ThemsAllTook | 7 | 18,420 |
Nov 5, 2011 05:20 PM Last Post: SethWillits |
|
| Help with Collision Detection..(i'm almost there) | carmine | 1 | 3,519 |
Jun 29, 2011 12:33 PM Last Post: ThemsAllTook |
|
| Seperating Axis Theorem Code | mikey | 5 | 3,630 |
Oct 9, 2010 03:25 PM Last Post: Oddity007 |
|
| Time Delta, collision detection | mk12 | 19 | 12,867 |
Sep 8, 2010 06:40 PM Last Post: AnotherJake |
|

