Continuous Collision Detection¶
- ipctk.is_step_collision_free(mesh: ipctk.CollisionMesh, vertices_t0: numpy.ndarray[numpy.float64[m, n]], vertices_t1: numpy.ndarray[numpy.float64[m, n]], min_distance: float = 0.0, broad_phase_method: ipctk.BroadPhaseMethod = <BroadPhaseMethod.HASH_GRID: 1>, narrow_phase_ccd: ipctk.NarrowPhaseCCD = <ipctk.TightInclusionCCD object at 0x7fbabfd2f970>) bool ¶
Determine if the step is collision free.
Note
Assumes the trajectory is linear.
- Parameters:¶
- mesh
The collision mesh.
- vertices_t0
Surface vertex vertices at start as rows of a matrix.
- vertices_t1
Surface vertex vertices at end as rows of a matrix.
- min_distance
The minimum distance allowable between any two elements.
- broad_phase_method
The broad phase method to use.
- narrow_phase_ccd
The narrow phase CCD algorithm to use.
- Returns:¶
True if <b>any</b> collisions occur.
- ipctk.compute_collision_free_stepsize(mesh: ipctk.CollisionMesh, vertices_t0: numpy.ndarray[numpy.float64[m, n]], vertices_t1: numpy.ndarray[numpy.float64[m, n]], min_distance: float = 0.0, broad_phase_method: ipctk.BroadPhaseMethod = <BroadPhaseMethod.HASH_GRID: 1>, narrow_phase_ccd: ipctk.NarrowPhaseCCD = <ipctk.TightInclusionCCD object at 0x7fbabfd2faf0>) float ¶
Computes a maximal step size that is collision free.
Note
Assumes the trajectory is linear.
- Parameters:¶
- mesh
The collision mesh.
- vertices_t0
Vertex vertices at start as rows of a matrix. Assumes vertices_t0 is intersection free.
- vertices_t1
Surface vertex vertices at end as rows of a matrix.
- min_distance
The minimum distance allowable between any two elements.
- broad_phase_method
The broad phase method to use.
- narrow_phase_ccd
The narrow phase CCD algorithm to use.
- Returns:¶
A step-size \(\in [0, 1]\) that is collision free. A value of 1.0 if a full step and 0.0 is no step.
Individual CCD Functions¶
Generic Interface¶
Tight Inclusion CCD¶
- ipctk.tight_inclusion.edge_edge_ccd(ea0_t0: numpy.ndarray[numpy.float64[3, 1]], ea1_t0: numpy.ndarray[numpy.float64[3, 1]], eb0_t0: numpy.ndarray[numpy.float64[3, 1]], eb1_t0: numpy.ndarray[numpy.float64[3, 1]], ea0_t1: numpy.ndarray[numpy.float64[3, 1]], ea1_t1: numpy.ndarray[numpy.float64[3, 1]], eb0_t1: numpy.ndarray[numpy.float64[3, 1]], eb1_t1: numpy.ndarray[numpy.float64[3, 1]], min_distance: float = 0, tmax: float = 1, tolerance: float = 1e-06, max_iterations: int = 10000000, filter: numpy.ndarray[numpy.float64[3, 1]] = array([-1., -1., -1.]), no_zero_toi: bool = False, ccd_method: ipctk.tight_inclusion.CCDRootFindingMethod = <CCDRootFindingMethod.BREADTH_FIRST_SEARCH: 1>) tuple[bool, float, float] ¶
Determine the earliest time of impact between two edges (optionally with a minimum separation).
- Parameters:¶
- ea0_t0
Starting position of the first vertex of the first edge.
- ea1_t0
Start position of the second vertex of the first edge.
- eb0_t0
Start position of the first vertex of the second edge.
- eb1_t0
Start position of the second vertex of the second edge.
- ea0_t1
End position of the first vertex of the first edge.
- ea1_t1
End position of the second vertex of the first edge.
- eb0_t1
End position of the first vertex of the second edge.
- eb1_t1
End position of the second vertex of the second edge.
- min_distance
Minimum separation distance (default: 0).
- tmax
Upper bound of the time interval [0,tmax] to be checked (0<=tmax<=1).
- tolerance
Solver tolerance (default: 1e-6).
- max_iterations
Maximum number of solver iterations (default: 1e7). If negative, solver will run until convergence.
- filter
Filters calculated using get_numerical_error (default: (-1,-1,-1)). Use (-1,-1,-1) if checking a single query.
- no_zero_toi
Refine further if a zero TOI is produced (assuming not initially in contact).
- ccd_method
Root finding method (default: BREADTH_FIRST_SEARCH).
- Returns:¶
True if there is a collision, false otherwise, the earliest time of collision if collision happens (infinity if no collision occurs), and if max_iterations < 0, the solver precision otherwise the input tolerance.
- Return type:¶
Tuple of
- ipctk.tight_inclusion.point_triangle_ccd(v_t0: numpy.ndarray[numpy.float64[3, 1]], f0_t0: numpy.ndarray[numpy.float64[3, 1]], f1_t0: numpy.ndarray[numpy.float64[3, 1]], f2_t0: numpy.ndarray[numpy.float64[3, 1]], v_t1: numpy.ndarray[numpy.float64[3, 1]], f0_t1: numpy.ndarray[numpy.float64[3, 1]], f1_t1: numpy.ndarray[numpy.float64[3, 1]], f2_t1: numpy.ndarray[numpy.float64[3, 1]], min_distance: float = 0, tmax: float = 1, tolerance: float = 1e-06, max_iterations: int = 10000000, filter: numpy.ndarray[numpy.float64[3, 1]] = array([-1., -1., -1.]), no_zero_toi: bool = False, ccd_method: ipctk.tight_inclusion.CCDRootFindingMethod = <CCDRootFindingMethod.BREADTH_FIRST_SEARCH: 1>) tuple[bool, float, float] ¶
Determine the earliest time of impact between a point and triangle (optionally with a minimum separation).
- Parameters:¶
- v_t0
Starting position of the vertex.
- f0_t0
Starting position of the first vertex of the face.
- f1_t0
Starting position of the second vertex of the face.
- f2_t0
Starting position of the third vertex of the face.
- v_t1
Ending position of the vertex.
- f0_t1
Ending position of the first vertex of the face.
- f1_t1
Ending position of the second vertex of the face.
- f2_t1
Ending position of the third vertex of the face.
- min_distance
Minimum separation distance (default: 0).
- tmax
Upper bound of the time interval [0,tmax] to be checked (0<=tmax<=1).
- tolerance
Solver tolerance (default: 1e-6).
- max_iterations
Maximum number of solver iterations (default: 1e7). If negative, solver will run until convergence.
- filter
Filters calculated using get_numerical_error (default: (-1,-1,-1)). Use (-1,-1,-1) if checking a single query.
- no_zero_toi
Refine further if a zero TOI is produced (assuming not initially in contact).
- ccd_method
Root finding method (default: BREADTH_FIRST_SEARCH).
- Returns:¶
True if there is a collision, false otherwise, the earliest time of collision if collision happens (infinity if no collision occurs), and if max_iterations < 0, the solver precision otherwise the input tolerance.
- Return type:¶
Tuple of
- ipctk.tight_inclusion.compute_ccd_filters(min_corner: numpy.ndarray[numpy.float64[3, 1]], max_corner: numpy.ndarray[numpy.float64[3, 1]], is_vertex_face: bool, using_minimum_separation: bool) numpy.ndarray[numpy.float64[3, 1]] ¶
Compute the numerical error filters for the input to the CCD solver.
Before you run the simulation, you need to conservatively estimate the axis-aligned bounding box in which the meshes will be located during the whole simulation process.
- Parameters:¶
- min_corner: numpy.ndarray[numpy.float64[3, 1]]¶
Minimum corner of the axis-aligned bounding box of the simulation scene.
- max_corner: numpy.ndarray[numpy.float64[3, 1]]¶
Maximum corner of the axis-aligned bounding box of the simulation scene.
- is_vertex_face: bool¶
True if checking vertex-face collision, false if checking edge-edge collision.
- using_minimum_separation: bool¶
True if using minimum separation CCD, false otherwise.
- Returns:¶
The numerical error filters for the input parameters.
Additive CCD¶
Generic Interface¶
Nonlinear CCD¶
- class ipctk.NonlinearTrajectory¶
Bases:
pybind11_object
Public Methods:
__init__
(self)__call__
(self, t)Compute the point's position at time t
max_distance_from_linear
(self, t0, t1)Compute the maximum distance from the nonlinear trajectory to a linearized trajectory
Inherited from
pybind11_object
-
__annotations__ =
{}
¶
- __call__(self, t: float) numpy.ndarray[numpy.float64[m, 1]] ¶
Compute the point’s position at time t
- __init__(self)¶
-
__module__ =
'ipctk'
¶
-
__annotations__ =
- class ipctk.IntervalNonlinearTrajectory¶
Bases:
NonlinearTrajectory
Public Methods:
__init__
(self)__call__
(*args, **kwargs)Overloaded function.
max_distance_from_linear
(self, t0, t1)Compute the maximum distance from the nonlinear trajectory to a linearized trajectory
Inherited from
NonlinearTrajectory
__init__
(self)__call__
(self, t)Compute the point's position at time t
max_distance_from_linear
(self, t0, t1)Compute the maximum distance from the nonlinear trajectory to a linearized trajectory
Inherited from
pybind11_object
-
__annotations__ =
{}
¶
- __call__(*args, **kwargs)¶
Overloaded function.
__call__(self: ipctk.IntervalNonlinearTrajectory, t: float) -> numpy.ndarray[numpy.float64[m, 1]]
Compute the point’s position at time t
__call__(self: ipctk.IntervalNonlinearTrajectory, t: filib::Interval) -> numpy.ndarray[filib::Interval[m, 1]]
Compute the point’s position over a time interval t
- __init__(self)¶
-
__module__ =
'ipctk'
¶
- max_distance_from_linear(self, t0: float, t1: float) float ¶
Compute the maximum distance from the nonlinear trajectory to a linearized trajectory
Note
This uses interval arithmetic to compute the maximum distance. If you know a tighter bound on the maximum distance, it is recommended to override this function.
-
__annotations__ =
-
ipctk.point_point_nonlinear_ccd(p0: ipctk.NonlinearTrajectory, p1: ipctk.NonlinearTrajectory, tmax: float =
1.0
, min_distance: float =0
, tolerance: float =1e-06
, max_iterations: int =10000000
, conservative_rescaling: float =0.8
) tuple[bool, float] ¶ Perform nonlinear CCD between two points moving along nonlinear trajectories.
- Parameters:¶
- p0: ipctk.NonlinearTrajectory¶
First point’s trajectory
- p1: ipctk.NonlinearTrajectory¶
Second point’s trajectory
- tmax: float =
1.0
¶ Maximum time to check for collision
- min_distance: float =
0
¶ Minimum separation distance between the two points
- tolerance: float =
1e-06
¶ Tolerance for the linear CCD algorithm
- max_iterations: int =
10000000
¶ Maximum number of iterations for the linear CCD algorithm
- conservative_rescaling: float =
0.8
¶ Conservative rescaling of the time of impact
- Returns:¶
True if the two points collide, false otherwise. Output time of impact
- Return type:¶
Tuple of
-
ipctk.point_edge_nonlinear_ccd(p: ipctk.NonlinearTrajectory, e0: ipctk.NonlinearTrajectory, e1: ipctk.NonlinearTrajectory, tmax: float =
1.0
, min_distance: float =0
, tolerance: float =1e-06
, max_iterations: int =10000000
, conservative_rescaling: float =0.8
) tuple[bool, float] ¶ Perform nonlinear CCD between a point and a linear edge moving along nonlinear trajectories.
- Parameters:¶
- p: ipctk.NonlinearTrajectory¶
Point’s trajectory
- e0: ipctk.NonlinearTrajectory¶
Edge’s first endpoint’s trajectory
- e1: ipctk.NonlinearTrajectory¶
Edge’s second endpoint’s trajectory
- tmax: float =
1.0
¶ Maximum time to check for collision
- min_distance: float =
0
¶ Minimum separation distance between the point and the edge
- tolerance: float =
1e-06
¶ Tolerance for the linear CCD algorithm
- max_iterations: int =
10000000
¶ Maximum number of iterations for the linear CCD algorithm
- conservative_rescaling: float =
0.8
¶ Conservative rescaling of the time of impact
- Returns:¶
True if the point and edge collide, false otherwise. Output time of impact
- Return type:¶
Tuple of
-
ipctk.edge_edge_nonlinear_ccd(ea0: ipctk.NonlinearTrajectory, ea1: ipctk.NonlinearTrajectory, eb0: ipctk.NonlinearTrajectory, eb1: ipctk.NonlinearTrajectory, tmax: float =
1.0
, min_distance: float =0
, tolerance: float =1e-06
, max_iterations: int =10000000
, conservative_rescaling: float =0.8
) tuple[bool, float] ¶ Perform nonlinear CCD between two linear edges moving along nonlinear trajectories.
- Parameters:¶
- ea0: ipctk.NonlinearTrajectory¶
First edge’s first endpoint’s trajectory
- ea1: ipctk.NonlinearTrajectory¶
First edge’s second endpoint’s trajectory
- eb0: ipctk.NonlinearTrajectory¶
Second edge’s first endpoint’s trajectory
- eb1: ipctk.NonlinearTrajectory¶
Second edge’s second endpoint’s trajectory
- tmax: float =
1.0
¶ Maximum time to check for collision
- min_distance: float =
0
¶ Minimum separation distance between the two edges
- tolerance: float =
1e-06
¶ Tolerance for the linear CCD algorithm
- max_iterations: int =
10000000
¶ Maximum number of iterations for the linear CCD algorithm
- conservative_rescaling: float =
0.8
¶ Conservative rescaling of the time of impact
- Returns:¶
True if the two edges collide, false otherwise. Output time of impact
- Return type:¶
Tuple of
-
ipctk.point_triangle_nonlinear_ccd(p: ipctk.NonlinearTrajectory, t0: ipctk.NonlinearTrajectory, t1: ipctk.NonlinearTrajectory, t2: ipctk.NonlinearTrajectory, tmax: float =
1.0
, min_distance: float =0
, tolerance: float =1e-06
, max_iterations: int =10000000
, conservative_rescaling: float =0.8
) tuple[bool, float] ¶ Perform nonlinear CCD between a point and a linear triangle moving along nonlinear trajectories.
- Parameters:¶
- p: ipctk.NonlinearTrajectory¶
Point’s trajectory
- t0: ipctk.NonlinearTrajectory¶
Triangle’s first vertex’s trajectory
- t1: ipctk.NonlinearTrajectory¶
Triangle’s second vertex’s trajectory
- t2: ipctk.NonlinearTrajectory¶
Triangle’s third vertex’s trajectory
- tmax: float =
1.0
¶ Maximum time to check for collision
- min_distance: float =
0
¶ Minimum separation distance between the two edges
- tolerance: float =
1e-06
¶ Tolerance for the linear CCD algorithm
- max_iterations: int =
10000000
¶ Maximum number of iterations for the linear CCD algorithm
- conservative_rescaling: float =
0.8
¶ Conservative rescaling of the time of impact
- Returns:¶
True if the point and triangle collide, false otherwise. Output time of impact
- Return type:¶
Tuple of
Generic Interface¶
-
ipctk.conservative_piecewise_linear_ccd(distance: collections.abc.Callable[[float], float], max_distance_from_linear: collections.abc.Callable[[float, float], float], linear_ccd: collections.abc.Callable[[float, float, float, bool, float], bool], tmax: float =
1.0
, min_distance: float =0
, conservative_rescaling: float =0.8
) tuple[bool, float] ¶ Perform conservative piecewise linear CCD of a nonlinear trajectories.
- Parameters:¶
- distance: collections.abc.Callable[[float], float]¶
Return the distance for a given time in [0, 1].
- max_distance_from_linear: collections.abc.Callable[[float, float], float]¶
Return the maximum distance from the linearized trajectory for a given time interval.
- linear_ccd: collections.abc.Callable[[float, float, float, bool, float], bool]¶
Perform linear CCD on a given time interval.
- tmax: float =
1.0
¶ Maximum time to check for collision.
- min_distance: float =
0
¶ Minimum separation distance between the objects.
- conservative_rescaling: float =
0.8
¶ Conservative rescaling of the time of impact.
- Returns:¶
Output time of impact.
- Return type:¶
Tuple of