Search code examples
algorithmcollision-detection

Determining the minimal number of axis to test against in the SAT (Separating Axis Theorem)


Most implementations of the SAT algorithm I've seen involve testing each axis in either shape being tested against for collisions. But I recently implemented the SAT algorithm in python and noticed that for every single test case that worked when testing against all axes of either shape, it ALSO worked for every case when testing against only the axes of the shape with the GREATEST number of sides.

However, I have absolutely no clue how to prove or disprove this theory and I have minimal mathematical knowledge in proofs. Could someone help me out and prove or disprove this theory that the only axes I need to test against for the SAT are the ones on the shape with the greatest number of sides?


Solution

  • If you have a triangle and a square and only check the square's axes (X and Y), it will yield an erroneous collision if it's only separated via the diagonal axis.

    Look at the picture for a better explain.

    SAT Collission