Module org.dyn4j

Package org.dyn4j.collision.narrowphase

Sub package of the Collision package handling narrow-phase collision detection, distance checking, and raycasting.

Narrow-phase collision detection is used to determine if two Convex Shapes penetrate, and if so, compute the vector of minimum magnitude able to push the Convex Shapes out of penetration.

The NarrowphaseDetectors can only perform on Convex Shapes. This allows for fast and simple algorithms. Non-convex shapes can be decomposed using a Decomposer into Convex pieces which can then be tested individually.

Even though the NarrowphaseDetectors are fast, performance can be improved substantially if a BroadphaseDetector is used to eliminate obvious non-penetrating pairs.

NarrowphaseDetectors return Penetration objects representing the vector of minimum magnitude able to push the Convex Shapes 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 NarrowphaseDetectors 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 FallbackConditions.

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 Shapes.

The DistanceDetectors can return a Separation object which contains the separation normal, distance and closest points.

The RaycastDetectors 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