- Object
-
- ConservativeAdvancement
-
- All Implemented Interfaces:
TimeOfImpactDetector
public class ConservativeAdvancement extends Object implements TimeOfImpactDetector
Implements the Conservative Advancement technique to solve for the time of impact.This method assumes that translation and rotation are linear and computes the time of impact within a given tolerance.
This method is described in "Continuous Collision Detection and Physics" by Erwin Coumans (Draft).
- Since:
- 1.2.0
- Version:
- 3.1.5
- Author:
- William Bittle
-
-
Field Summary
Fields Modifier and Type Field Description static double
DEFAULT_DISTANCE_EPSILON
The default distance epsilonstatic int
DEFAULT_MAX_ITERATIONS
The default maximum number of iterations
-
Constructor Summary
Constructors Constructor Description ConservativeAdvancement()
Default constructor.ConservativeAdvancement(DistanceDetector distanceDetector)
Optional constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DistanceDetector
getDistanceDetector()
Returns theDistanceDetector
that is used.double
getDistanceEpsilon()
Returns the distance epsilon used to determine when a sufficient solution has been found.int
getMaxIterations()
Returns the maximum number of iterations that will be performed by the root finder.boolean
getTimeOfImpact(Convex convex1, Transform transform1, Vector2 dp1, double da1, Convex convex2, Transform transform2, Vector2 dp2, double da2, double t1, double t2, TimeOfImpact toi)
boolean
getTimeOfImpact(Convex convex1, Transform transform1, Vector2 dp1, double da1, Convex convex2, Transform transform2, Vector2 dp2, double da2, TimeOfImpact toi)
void
setDistanceDetector(DistanceDetector distanceDetector)
Sets theDistanceDetector
to be used.void
setDistanceEpsilon(double distanceEpsilon)
Sets the distance epsilon used to determine when a sufficient solution has been found.void
setMaxIterations(int maxIterations)
Sets the maximum number of iterations that will be performed by the root finder.
-
-
-
Field Detail
-
DEFAULT_DISTANCE_EPSILON
public static final double DEFAULT_DISTANCE_EPSILON
The default distance epsilon
-
DEFAULT_MAX_ITERATIONS
public static final int DEFAULT_MAX_ITERATIONS
The default maximum number of iterations- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ConservativeAdvancement
public ConservativeAdvancement()
Default constructor.Uses
Gjk
as theDistanceDetector
.
-
ConservativeAdvancement
public ConservativeAdvancement(DistanceDetector distanceDetector)
Optional constructor.- Parameters:
distanceDetector
- the distance detector- Throws:
NullPointerException
- if distanceDetector is null
-
-
Method Detail
-
getTimeOfImpact
public boolean getTimeOfImpact(Convex convex1, Transform transform1, Vector2 dp1, double da1, Convex convex2, Transform transform2, Vector2 dp2, double da2, TimeOfImpact toi)
Description copied from interface:TimeOfImpactDetector
Detects whether the givenConvex
Shape
s collide given their current positions and orientation and the rate of change their position and orientation, returning the time of impact within an epsilon.If a collision is detected, the
toi
parameter will be filled with the time of impact and the separation at the time of impact.If a time of impact is detected, the time will be in the range [0, 1]. This can be used, along with the change and position and orientation, to place to the shapes at the time of impact. Note that the shapes will still be separated, by a small amount, at the time of impact.
This method returns false if the shape do not collide.
- Specified by:
getTimeOfImpact
in interfaceTimeOfImpactDetector
- Parameters:
convex1
- the first convex shapetransform1
- the first convex shape's transformdp1
- the change in position of the first shapeda1
- the change in orientation of the first shapeconvex2
- the second convex shapetransform2
- the second convex shape's transformdp2
- the change in position of the second shapeda2
- the change in orientation of the second shapetoi
- theTimeOfImpact
object to be filled in the case of a collision- Returns:
- boolean true if a collision was detected
-
getTimeOfImpact
public boolean getTimeOfImpact(Convex convex1, Transform transform1, Vector2 dp1, double da1, Convex convex2, Transform transform2, Vector2 dp2, double da2, double t1, double t2, TimeOfImpact toi)
Description copied from interface:TimeOfImpactDetector
Detects whether the givenConvex
Shape
s collide given their current positions and orientation and the rate of change their position and orientation in the time range of [t1, t2] and returning the time of impact within an epsilon.If a collision is detected, the
toi
parameter will be filled with the time of impact and the separation at the time of impact.If a time of impact is detected, the time will be in the range [0, 1]. This can be used, along with the change and position and orientation, to place to the shapes at the time of impact. Note that the shapes will still be separated, by a small amount, at the time of impact.
This method returns false if the shape do not collide.
- Specified by:
getTimeOfImpact
in interfaceTimeOfImpactDetector
- Parameters:
convex1
- the first convex shapetransform1
- the first convex shape's transformdp1
- the change in position of the first shapeda1
- the change in orientation of the first shapeconvex2
- the second convex shapetransform2
- the second convex shape's transformdp2
- the change in position of the second shapeda2
- the change in orientation of the second shapet1
- the lower time boundt2
- the upper time boundtoi
- theTimeOfImpact
object to be filled in the case of a collision- Returns:
- boolean true if a collision was detected
-
getDistanceDetector
public DistanceDetector getDistanceDetector()
Returns theDistanceDetector
that is used.- Returns:
DistanceDetector
-
setDistanceDetector
public void setDistanceDetector(DistanceDetector distanceDetector)
Sets theDistanceDetector
to be used.- Parameters:
distanceDetector
- the distance detector- Throws:
NullPointerException
- if distanceDetector is null
-
getDistanceEpsilon
public double getDistanceEpsilon()
Returns the distance epsilon used to determine when a sufficient solution has been found.- Returns:
- double the distance epsilon
-
setDistanceEpsilon
public void setDistanceEpsilon(double distanceEpsilon)
Sets the distance epsilon used to determine when a sufficient solution has been found.- Parameters:
distanceEpsilon
- the distance epsilon; must be greater than zero- Throws:
IllegalArgumentException
- if distanceEpsilon is less than or equal to zero
-
getMaxIterations
public int getMaxIterations()
Returns the maximum number of iterations that will be performed by the root finder.- Returns:
- the maximum number of iterations the root finder will perform
-
setMaxIterations
public void setMaxIterations(int maxIterations)
Sets the maximum number of iterations that will be performed by the root finder.Lower values increase performance yet decrease accuracy whereas higher values decrease performance and increase accuracy.
- Parameters:
maxIterations
- the maximum number of iterations in the range [5, ∞]- Throws:
IllegalArgumentException
- if maxIterations is less than 5
-
-