Separating Axis Collision Detection

Nibbie
Posts: 1
Joined: 2010.11
Post: #1
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.
Quote this message in a reply
Sage
Posts: 1,482
Joined: 2002.09
Nibbie
Posts: 1
Joined: 2010.11
Post: #3
Skorche Wrote:http://www.harveycartel.org/metanet/tuto...rialA.html
Thanks, 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.
Quote this message in a reply
DoG
Moderator
Posts: 869
Joined: 2003.01
Post: #4
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.
Quote this message in a reply
Moderator
Posts: 529
Joined: 2003.03
Post: #5

"Yes, well, that's the sort of blinkered, Philistine pig-ignorance I've come to expect from you non-creative garbage."
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Optimize the collision detection alaslipknot 1 2,613 May 12, 2013 08:02 PM
Last Post: SethWillits
  Collision detection tutorial ThemsAllTook 7 22,483 Nov 5, 2011 05:20 PM
Last Post: SethWillits
  Help with Collision Detection..(i'm almost there) carmine 1 4,584 Jun 29, 2011 12:33 PM
Last Post: ThemsAllTook
  Seperating Axis Theorem Code mikey 5 4,552 Oct 9, 2010 03:25 PM
Last Post: Oddity007
  Time Delta, collision detection mk12 19 15,394 Sep 8, 2010 06:40 PM
Last Post: AnotherJake