Package org.dyn4j.collision.narrowphase
Narrowphase collision detection is used to determine if two Convex
Shape
s penetrate, and if so, compute the vector of minimum magnitude
able to push the Convex
Shape
s out
of penetration.
The NarrowphaseDetector
s can only perform on
Convex
Shape
s. This allows for fast
and simple algorithms. Nonconvex shapes can be decomposed using a Decomposer
into Convex
pieces which can then be tested individually.
Even though the NarrowphaseDetector
s are fast, performance
can be improved substantially if a BroadphaseDetector
is
used to eliminate obvious nonpenetrating pairs.
NarrowphaseDetector
s return
Penetration
objects representing the vector of minimum
magnitude able to push the Convex
Shape
s out
of penetration. This information is typically passed onto a ManifoldSolver
to find the collision points.
There are two NarrowphaseDetector
implementations provided:
Sat
and Gjk
.
NOTE: The Sat
algorithm doesn't
support the Ellipse
and HalfEllipse
shapes.
This package also contains a FallbackNarrowphaseDetector
class. This class is
used to build a hierarchy of NarrowphaseDetector
s that can select detection
algorithms based on arbitrary conditions. For example, in the case of Ellipse
and
HalfEllipse
, Gjk
could be the fallback detector while
Sat
is the primary. Fallback is determined by the assigned
FallbackCondition
s.
NOTE: The CircleDetector
and SegmentDetector
classes already being used in the Sat
and Gjk
classes so no FallbackNarrowphaseDetector
is necessary for these.
The Gjk
algorithm also implements the DistanceDetector
and RaycastDetector
interfaces. These interfaces allow performing distance checks and raycasts
against Convex
Shape
s.
The DistanceDetector
s can return a Separation
object which contains the separation normal, distance and closest points.
The RaycastDetector
s can return a Raycast
object which contains the point the Ray
intersects the shape, the normal and the
distance. For raycasting, it's also advisable to perform a raycast against a BroadphaseDetector
first to rule out the obvious failures.
 Since:
 1.0.0
 Version:
 3.2.0
 Author:
 William Bittle

Interface Summary Interface Description DistanceDetector FallbackCondition Represents a condition that returns true to indicate a fallbackNarrowphaseDetector
should be used instead of the primary.MinkowskiPenetrationSolver Interface representing a sub algorithm for finding the penetration vector and depth using properties of theMinkowskiSum
and theGjk
termination information.NarrowphaseDetector NarrowphasePostProcessor Interface used to modify the narrowphase collision information before being sent to listeners.RaycastDetector 
Class Summary Class Description AbstractFallbackCondition Abstract implementation of theFallbackCondition
interface.CircleDetector Class devoted toCircle
detection queries.Epa FallbackNarrowphaseDetector Represents a delegatingNarrowphaseDetector
that uses a primaryNarrowphaseDetector
and fallbackNarrowphaseDetector
.Gjk Implementation of the GilbertJohnsonKeerthi (GJK) algorithm for collision detection.LinkPostProcessor ANarrowphasePostProcessor
specifically for theLink
class to solve the internal edge problem when using a chain of segments.MinkowskiSum MinkowskiSumPoint Represents a point in theMinkowskiSum
.PairwiseTypedFallbackCondition Represents aTypedFallbackCondition
that filters on a particular pair of types.Penetration Raycast Sat Implementation of the Separating Axis Theorem (SAT) for collision detection.SegmentDetector Class devoted to improving performance ofSegment
detection queries.Separation SingleTypedFallbackCondition Represents aTypedFallbackCondition
that filters on a single type.TypedFallbackCondition Represents aFallbackCondition
that uses theConvex
's class type to determine which pairs will be detected by the fallbackNarrowphaseDetector
.