Separating Axis Theorem: Polygon Collision Detection for Physics Engines

Added:

The GJK Algorithm and Minkowski Difference Methods

While the Separating Axis Theorem (SAT) is a popular method for 2D convex polygon collision detection, it exhibits significant drawbacks when scaled to 3D or highly complex shapes. In 3D, SAT requires testing a large number of axes (including cross products of all edges), leading to performance bottlenecks. Additionally, SAT does not natively support non-polyhedral shapes (like spheres or capsules) and requires complex post-processing clipping to find contact points. As a superior alternative in many contexts, modern physics engines widely prefer the GJK (Gilbert-Johnson-Keerthi) algorithm, often paired with the EPA (Expansion Polytope Algorithm). GJK operates on the Minkowski difference of two shapes using support functions. This mathematical approach offers near-linear or logarithmic complexity, scales gracefully to 3D, natively supports curved geometries, and directly provides distance and penetration depth data, making it the industry standard for engines like PhysX and Bullet.

Vector Mathematics: Mastery of vector operations, specifically dot products, 2D projections, and calculating perpendicular normal vectors.
Geometric Properties of Polygons: Understanding the mathematical definition of convex versus concave shapes, as SAT natively only supports convex polygons.
Coordinate Space Representations: Representing 2D shapes programmatically as ordered lists of vertex coordinates in Cartesian space.
Basic Bounding Volumes: Conceptual familiarity with simpler collision detection methods like Axis-Aligned Bounding Boxes (AABB).
Collision Resolution: Calculating the Minimum Translation Vector (MTV) to resolve overlaps and applying physical impulses (forces, velocities) to bodies.
Concave Polygon Decomposition: Utilizing algorithms (e.g., triangulation or Hertel-Mehlhorn) to break complex concave shapes into convex pieces for SAT compatibility.
Broad-Phase Optimization: Implementing spatial partitioning structures like Quadtrees or Sweep-and-Prune to reduce the number of expensive SAT checks.
3D Separating Axis Theorem: Extending the mathematical principles of SAT to 3D meshes, incorporating face normals and edge-pair cross products.
Continuous Collision Detection (CCD): Addressing 'tunneling' issues for high-speed objects using swept volume techniques or time-of-impact calculation.
34.3K views1.1Klikes32:07@pikumaOriginal Release: 2021-07-14

The Separating Axis Theorem (SAT) is a collision detection algorithm that determines whether two convex polygons are colliding by checking if there exists at least one axis where their projections do not overlap; the algorithm works by projecting both polygons onto the normal vectors of each edge and checking for separation, returning true if any separating axis is found and false otherwise.