- Object
-
- Epa
-
- All Implemented Interfaces:
MinkowskiPenetrationSolver
public class Epa extends Object implements MinkowskiPenetrationSolver
Epa
, or Expanding Polytope Algorithm, is used to find the penetration depth and vector given the final simplex ofGjk
.Epa
expands the given simplex in the direction of the origin until it cannot be expanded any further.Gjk
guarantees that the simplex points are on the edge of the Minkowski sum which creates a convex polytope from which to start theEpa
algorithm.Expansion is achieved by breaking edges of the simplex. Find the edge on the simplex closest to the origin, then use that edge's normal to find another support point (using the same support method that
Gjk
uses). Add the new support point to the simplex between the points that made the closest edge. Repeat this process until the polytope cannot be expanded further.This implementation has three termination cases:
- If the new support point is not past the edge along the edge normal given some epsilon.
- If the distance between the last support point and the new support point is below a given epsilon.
- Maximum iteration count.
Epa
terminates, the penetration vector is the current closest edge normal and the penetration depth is the distance from the origin to the edge along the normal.Epa
will terminate in a finite number of iterations if the two shapes arePolygon
s. If either shape has curved surfaces the algorithm requires an expected accuracy epsilon:distanceEpsilon
. In the case that thedistanceEpsilon
is too small, themaxIterations
will prevent the algorithm from running forever.- Since:
- 1.0.0
- Version:
- 5.0.0
- Author:
- William Bittle
- See Also:
Gjk
, EPA (Expanding Polytope Algorithm)
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_DISTANCE_EPSILON
The defaultEpa
distance epsilon in meters; near 1E-8static int
DEFAULT_MAX_ITERATIONS
The defaultEpa
maximum iterationsprotected double
distanceEpsilon
TheEpa
distance epsilon in metersprotected int
maxIterations
The maximum number ofEpa
iterations
-
Constructor Summary
Constructors Constructor Description Epa()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getDistanceEpsilon()
Returns the distance epsilon.int
getMaxIterations()
Returns the maximum number of iterations the algorithm will perform before exiting.void
getPenetration(List<Vector2> simplex, MinkowskiSum minkowskiSum, Penetration penetration)
Returns the penetration vector and depth in the givenPenetration
objectvoid
setDistanceEpsilon(double distanceEpsilon)
The minimum distance between two iterations of the algorithm.void
setMaxIterations(int maxIterations)
Sets the maximum number of iterations the algorithm will perform before exiting.
-
-
-
Field Detail
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS
The defaultEpa
maximum iterations- See Also:
- Constant Field Values
-
DEFAULT_DISTANCE_EPSILON
public static final double DEFAULT_DISTANCE_EPSILON
The defaultEpa
distance epsilon in meters; near 1E-8
-
maxIterations
protected int maxIterations
The maximum number ofEpa
iterations
-
distanceEpsilon
protected double distanceEpsilon
TheEpa
distance epsilon in meters
-
-
Method Detail
-
getPenetration
public void getPenetration(List<Vector2> simplex, MinkowskiSum minkowskiSum, Penetration penetration)
Description copied from interface:MinkowskiPenetrationSolver
Returns the penetration vector and depth in the givenPenetration
objectNOTE: It's the responsibility of the caller to clear the given
Penetration
object before calling this method. given the final simplex fromGjk
andMinkowskiSum
.- Specified by:
getPenetration
in interfaceMinkowskiPenetrationSolver
- Parameters:
simplex
- the simplex containing the originminkowskiSum
- theMinkowskiSum
penetration
- thePenetration
object to fill
-
getMaxIterations
public int getMaxIterations()
Returns the maximum number of iterations the algorithm will perform before exiting.- Returns:
- int
- See Also:
setMaxIterations(int)
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations the algorithm will perform before exiting.- Parameters:
maxIterations
- the maximum number of iterations in the range [5, ∞]- Throws:
IllegalArgumentException
- if maxIterations is less than 5
-
getDistanceEpsilon
public double getDistanceEpsilon()
Returns the distance epsilon.- Returns:
- double
- See Also:
setDistanceEpsilon(double)
-
setDistanceEpsilon
public void setDistanceEpsilon(double distanceEpsilon)
The minimum distance between two iterations of the algorithm.The distance epsilon is used to determine when the algorithm is close enough to the edge of the minkowski sum to conclude that it can no longer expand. This is primarily used when one of the
Convex
Shape
s in question has a curved shape.- Parameters:
distanceEpsilon
- the distance epsilon in the range (0, ∞]- Throws:
IllegalArgumentException
- if distanceEpsilon is less than or equal to zero
-
-