forghani77-gi: The Separating Axis Theorem (SAT) is a technique used in computer graphics and collision detection to determine whether two objects are overlapping or not.
To understand SAT, let's consider two convex polygons. A polygon is convex if all the line segments connecting any two points on the polygon lie inside the polygon itself.
The main idea of SAT is to check if there exists a separating axis between the two polygons. A separating axis is a line or vector that, if extended infinitely in both directions, divides the two polygons completely. In other words, there is no overlap between the projections of the polygons onto this separating axis.
To apply SAT, we need to perform the following steps:
1. Check for overlapping bounding boxes: First, we check if the axis-aligned bounding boxes (bounding rectangles) of the two polygons intersect. If they don't, then the polygons are not overlapping, and we can stop the check.
2. Find potential separating axes: If the bounding boxes intersect, we proceed to find potential separating axes. For each polygon, we consider its edges and perpendicularly project the polygons onto these edges to obtain a set of candidate separating axes.
3. Test for separation: We need to verify if any of the potential axes actually separate the polygons. To do this, we project the polygons onto each of the candidate axes and check if the resulting intervals overlap. If any of the intervals do not overlap, then a separating axis has been found, and the polygons are not overlapping.
If we can find a separating axis, we can conclude that the polygons are not overlapping. If no separating axis is found, it means the polygons are overlapping and we can proceed with further calculations (such as resolving the collision).
The beauty of SAT is that it works for any pair of convex polygons, regardless of their shape or orientation. It provides an efficient and reliable method for collision detection in 2D environments.
In summary, the Separating Axis Theorem is a technique used in collision detection to determine if two convex polygons overlap or not by testing potential separating axes between them. It serves as a foundation for various algorithms used in computer graphics and physics simulations.