Swept Separating Axis Theorem Circle -> Poly

Monkey Forums/Monkey Programming/Swept Separating Axis Theorem Circle -> Poly

NoOdle(Posted 2013) [#1]
I've been learning the Separating Axis Theorem over the last few days and I've managed to implement several different methods. Circle - Circle, AABB - AABB, AABB - Poly, Poly - Poly. I almost have Circle - Poly working but I need more information on the algorithm. I am noticing some errors when the circle is colliding with the vertices.

Im not sure what foci axis to use, if doing the test stationary you use the vector pointing from the circle to closest vertex, this doesn't work with moving shapes. I would be really grateful if anyone has any idea where I can find some information on this. I think I have exhausted my google searching skills...

I have a botched version that works (tests 24 axis to represent a circle ouch!!) but I really would like to fix it up as static circle -> poly is much quicker than poly -> poly so swept should be solved quicker too..


Jesse(Posted 2013) [#2]
I was researching that a while back. I found a couple of sites that I cant recall anymore. But they were too advanced for me. They used calculus and physics equations I couldn't understand. sometime in the future(past) I wanted to make a pinball game but I could never get the flipper to interact properly with the ball. I posted it in here in this thread:

http://www.monkeycoder.co.nz/Community/posts.php?topic=1169#10411

The closest I got was a post from Warpy but I couldn't really figure out his code. I am not saying this will help you and more than likely not at all but maybe It will.


NoOdle(Posted 2013) [#3]
Thanks Jesse that helped and lead me to find this article:
http://www.geometrictools.com/Documentation/IntersectionMovingSphereTriangle.pdf
Quickly glanced through it and seems to be exactly what I need to get mine working, I wasn't sure how to test voronoi regions properly!


Rus(Posted 2013) [#4]
One way I've used to do this is:
- find the nearest point on the other polygon.
- find the line between this point and the center of the circle.
- add this line as one of the separating axes to test.

This article may explain it more clearly.
http://www.sevenson.com.au/actionscript/sat/


Tibit(Posted 2013) [#5]
Awesome tutorial on SAT (you probably have seen it, but if you haven't)
http://www.metanetsoftware.com/technique/tutorialA.html


NoOdle(Posted 2013) [#6]
Thank you Tibit, the tutorialA is good but they have hard coded their voronoi regions and shapes so it makes it hard to expand or understand. If anyone wants, I can post a monkey port of their code.
This article may explain it more clearly.
http://www.sevenson.com.au/actionscript/sat/

Thanks, I found that website a few months ago and implemented the axis you mentioned. This works great for static shapes, but for moving shapes this no longer works. I have moving poly -> poly working but I need to figure out how to handle the additional separating axis for moving circle -> poly. Hopefully its something as simple as a mistake in my implementation rather than changes required to the algorithm...


AdamRedwoods(Posted 2013) [#7]
a moving circle's center creates a line. project the line+radius+radius (at both ends, unless you dont care about the start position) onto your axis plane.


Tibit(Posted 2013) [#8]
I used this example a while back. I can't find the source, but I put it up on my ftp.

I think this might be what you are looking for:
PollyColly - Examples, Code, Documentation

He explains in the docs how the math works in each example.


Paul - Taiphoz(Posted 2013) [#9]
I would love to see the monkey example if you have it, complex maths kicks my ass most of the time, so seeing an example in a language I understand can really help me get my head around it.


NoOdle(Posted 2013) [#10]
I think this might be what you are looking for:
PollyColly - Examples, Code, Documentation

Thank you that does look very promising, ill have to give them a proper read when Ive shaken this rather evil hangover!

I would love to see the monkey example if you have it

Sure thing, I'll post it in the code archives tomorrow.