# Comparing axes in a SAT based collision resolution method

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

## Recommended Posts

I've implemented a Separating Axis Theorem-based collision detection function (in C++) and am now dealing with resolving collisions. What I need to figure out is how to detect which axis is best to resolve the collision.
What would be a good way to compare several vectors to an inverted translation vector in order to determine which axis will result in the best possible collision (basically the axis closest to the translation vector)?

I think I could use something like each normal in the static object stored an angle (0-360, probably 9 bits, or an int, whatever) and the translation vector structure also contained an angle (for now it's limited to increments of 45 because of keyboard-based controls). The static angles would all be compared to the translation angle, and the closest static normal would be used as the resolution vector.

Is there anything more efficient/better to use to compare the vectors, or should I use a completely different method in order to resolve the collisions?

##### Share on other sites
What I need to figure out is how to detect which axis is best to resolve the collision.[/quote]
In SAT it's axis with minimal projection overlaping.

##### Share on other sites
If there is a collision the objects have no separating axis. Maybe you want to find the direction along which two overlapping objects need to be displaced by the minimum amount to cease overlapping, but it's a mere hack.
For an exact collision response you have to compute the time of impact and the position of objects when they touch. At that time and place, the objects bounce, start deforming, etc.

##### Share on other sites
In SAT it's axis with minimal projection overlaping.[/quote]
The reason why I don't do that is because when the objects near each other's corners the minimal axis becomes the axis on the wrong side of the shape, making a horrible tunneling effect.

I'm not really making an exact collision detection method, just a simple, versatile one for basic game collisions.

How difficult is it on the CPU to compute the time/position of impact? I'd imagine to use a method where it splits the total translation in half, sees if there is a collision or not, then splits a portion of that in half and so on.

##### Share on other sites
The reason why I don't do that is because when the objects near each other's corners the minimal axis becomes the axis on the wrong side of the shape, making a horrible tunneling effect.[/quote]
Then you definitelly need time prediction algorithm. The same SAT is good. I wrote a post long time ago - check it out

##### Share on other sites
Great tutorial! It ws a little hard to read, but your English is pretty good. Thanks for the help!

1. 1
2. 2
3. 3
frob
12
4. 4
5. 5
Rutin
10

• 13
• 14
• 65
• 14
• 15
• ### Forum Statistics

• Total Topics
632130
• Total Posts
3004284

×