- Object
-
- Sat
-
- All Implemented Interfaces:
ContainmentDetector
,NarrowphaseDetector
public class Sat extends Object implements NarrowphaseDetector, ContainmentDetector
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:
- 4.2.1
- 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
contains(Convex convex1, Transform transform1, Convex convex2, Transform transform2, Containment containment)
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.NOTE: It's the responsibility of the caller to clear the given
Penetration
object before calling this method.
-
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
.
-
contains
public boolean contains(Convex convex1, Transform transform1, Convex convex2, Transform transform2, Containment containment)
Description copied from interface:ContainmentDetector
Returns true if one of theConvex
Shape
s are contained in the other.4NOTE: It's the responsibility of the caller to clear the given
Containment
object before calling this method.- Specified by:
contains
in interfaceContainmentDetector
- Parameters:
convex1
- the firstShape
transform1
- the firstShape
'sTransform
convex2
- the secondShape
transform2
- the secondShape
'sTransform
containment
- theContainment
object to fill- Returns:
- boolean true if one of the
Convex
Shape
s is contained in the other
-
-