- Object
-
- Sat
-
- All Implemented Interfaces:
NarrowphaseDetector
public class Sat extends Object implements NarrowphaseDetector
Implementation of the Separating Axis Theorem (SAT) for collision detection.Sat
states that "if twoConvex
objects are not penetrating, there exists an axis (vector) for which the projection of the objects does not overlap."The axes that must be tested are all the edge normals of both
Convex
Shape
s. For each edge normal we project theConvex
Shape
s onto it yielding a 1 dimensionalInterval
. If anyInterval
doesn't overlap, then we can conclude theConvex
Shape
s do not intersect. If all theInterval
s overlap, then we can conclude that theConvex
Shape
s intersect.If the
Convex
Shape
s are penetrating, aPenetration
object can be built from theInterval
s with the least overlap. The normal will be the edge normal of theInterval
and the depth will be theInterval
overlap.- Since:
- 1.0.0
- Version:
- 3.0.2
- Author:
- William Bittle
- See Also:
- SAT (Separating Axis Theorem)
-
-
Constructor Summary
Constructors Constructor Description Sat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
detect(Convex convex1, Transform transform1, Convex convex2, Transform transform2)
boolean
detect(Convex convex1, Transform transform1, Convex convex2, Transform transform2, Penetration penetration)
Returns true if the twoConvex
Shape
s intersect and fills thePenetration
object with the penetration vector and depth.
-
-
-
Method Detail
-
detect
public boolean detect(Convex convex1, Transform transform1, Convex convex2, Transform transform2, Penetration penetration)
Description copied from interface:NarrowphaseDetector
Returns true if the twoConvex
Shape
s intersect and fills thePenetration
object with the penetration vector and depth.
-
detect
public boolean detect(Convex convex1, Transform transform1, Convex convex2, Transform transform2)
Description copied from interface:NarrowphaseDetector
Returns true if the twoConvex
Shape
s intersect.Used to quickly test if two
Convex
Shape
s intersect without incurring the cost of determiningPenetration
.
-
-