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 0x7f9077a9b1f0>) 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 0x7f9077ae68b0>) 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.

Narrow Phase CCD

class ipctk.NarrowPhaseCCD

Bases: pybind11_object

Public Methods:

__init__(*args, **kwargs)

point_point_ccd(self, p0_t0, p1_t0, p0_t1, p1_t1)

point_edge_ccd(self, p_t0, e0_t0, e1_t0, ...)

point_triangle_ccd(self, p_t0, t0_t0, t1_t0, ...)

edge_edge_ccd(self, ea0_t0, ea1_t0, eb0_t0, ...)

Inherited from pybind11_object

__annotations__ = {}
__init__(*args, **kwargs)
__module__ = 'ipctk'
edge_edge_ccd(self, 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.0, tmax: float = 1.0) tuple[bool, float]
point_edge_ccd(self, p_t0: numpy.ndarray[numpy.float64[m, 1]], e0_t0: numpy.ndarray[numpy.float64[m, 1]], e1_t0: numpy.ndarray[numpy.float64[m, 1]], p_t1: numpy.ndarray[numpy.float64[m, 1]], e0_t1: numpy.ndarray[numpy.float64[m, 1]], e1_t1: numpy.ndarray[numpy.float64[m, 1]], min_distance: float = 0.0, tmax: float = 1.0) tuple[bool, float]
point_point_ccd(self, p0_t0: numpy.ndarray[numpy.float64[m, 1]], p1_t0: numpy.ndarray[numpy.float64[m, 1]], p0_t1: numpy.ndarray[numpy.float64[m, 1]], p1_t1: numpy.ndarray[numpy.float64[m, 1]], min_distance: float = 0.0, tmax: float = 1.0) tuple[bool, float]
point_triangle_ccd(self, p_t0: numpy.ndarray[numpy.float64[3, 1]], t0_t0: numpy.ndarray[numpy.float64[3, 1]], t1_t0: numpy.ndarray[numpy.float64[3, 1]], t2_t0: numpy.ndarray[numpy.float64[3, 1]], p_t1: numpy.ndarray[numpy.float64[3, 1]], t0_t1: numpy.ndarray[numpy.float64[3, 1]], t1_t1: numpy.ndarray[numpy.float64[3, 1]], t2_t1: numpy.ndarray[numpy.float64[3, 1]], min_distance: float = 0.0, tmax: float = 1.0) tuple[bool, float]

Tight Inclusion CCD

class ipctk.TightInclusionCCD

Bases: NarrowPhaseCCD

Public Data Attributes:

DEFAULT_TOLERANCE

DEFAULT_MAX_ITERATIONS

DEFAULT_CONSERVATIVE_RESCALING

SMALL_TOI

tolerance

Solver tolerance.

max_iterations

Maximum number of iterations.

conservative_rescaling

Conservative rescaling of the time of impact.

Public Methods:

__init__(self[, tolerance, max_iterations, ...])

Construct a new AdditiveCCD object.

Inherited from NarrowPhaseCCD

__init__(*args, **kwargs)

point_point_ccd(self, p0_t0, p1_t0, p0_t1, p1_t1)

point_edge_ccd(self, p_t0, e0_t0, e1_t0, ...)

point_triangle_ccd(self, p_t0, t0_t0, t1_t0, ...)

edge_edge_ccd(self, ea0_t0, ea1_t0, eb0_t0, ...)

Inherited from pybind11_object

DEFAULT_CONSERVATIVE_RESCALING = 0.8
DEFAULT_MAX_ITERATIONS = 10000000
DEFAULT_TOLERANCE = 1e-06
SMALL_TOI = 1e-06
__annotations__ = {}
__init__(self, tolerance: float = 1e-06, max_iterations: int = 10000000, conservative_rescaling: float = 0.8)

Construct a new AdditiveCCD object.

Parameters:
conservative_rescaling: float = 0.8

The conservative rescaling of the time of impact.

__module__ = 'ipctk'
property conservative_rescaling : float

Conservative rescaling of the time of impact.

property max_iterations : int

Maximum number of iterations.

property tolerance : float

Solver tolerance.

Additive CCD

class ipctk.AdditiveCCD

Bases: NarrowPhaseCCD

Public Data Attributes:

DEFAULT_CONSERVATIVE_RESCALING

conservative_rescaling

The conservative rescaling value used to avoid taking steps exactly to impact.

Public Methods:

__init__(self[, max_iterations, ...])

Construct a new AdditiveCCD object.

Inherited from NarrowPhaseCCD

__init__(*args, **kwargs)

point_point_ccd(self, p0_t0, p1_t0, p0_t1, p1_t1)

point_edge_ccd(self, p_t0, e0_t0, e1_t0, ...)

point_triangle_ccd(self, p_t0, t0_t0, t1_t0, ...)

edge_edge_ccd(self, ea0_t0, ea1_t0, eb0_t0, ...)

Inherited from pybind11_object

DEFAULT_CONSERVATIVE_RESCALING = 0.9
__annotations__ = {}
__init__(self, max_iterations: float = 10000000, conservative_rescaling: float = 0.9)

Construct a new AdditiveCCD object.

Parameters:
conservative_rescaling: float = 0.9

The conservative rescaling of the time of impact.

__module__ = 'ipctk'
property conservative_rescaling : float

The conservative rescaling value used to avoid taking steps exactly to impact.

Inexact CCD

Note

This method is disabled by default. To enable it, set the IPC_TOOLKIT_WITH_INEXACT_CCD CMake option to ON.

ipctk.inexact_point_edge_ccd_2D(p_t0: numpy.ndarray[numpy.float64[2, 1]], e0_t0: numpy.ndarray[numpy.float64[2, 1]], e1_t0: numpy.ndarray[numpy.float64[2, 1]], p_t1: numpy.ndarray[numpy.float64[2, 1]], e0_t1: numpy.ndarray[numpy.float64[2, 1]], e1_t1: numpy.ndarray[numpy.float64[2, 1]], conservative_rescaling: float) tuple[bool, float]

Inexact continuous collision detection between a point and an edge in 2D.

Parameters:
p_t0: numpy.ndarray[numpy.float64[2, 1]]

Initial position of the point

e0_t0: numpy.ndarray[numpy.float64[2, 1]]

Initial position of the first endpoint of the edge

e1_t0: numpy.ndarray[numpy.float64[2, 1]]

Initial position of the second endpoint of the edge

p_t1: numpy.ndarray[numpy.float64[2, 1]]

Final position of the point

e0_t1: numpy.ndarray[numpy.float64[2, 1]]

Final position of the first endpoint of the edge

e1_t1: numpy.ndarray[numpy.float64[2, 1]]

Final position of the second endpoint of the edge

conservative_rescaling: float

Conservative rescaling of the time of impact

Returns:

True if a collision was detected, false otherwise. Output time of impact

Return type:

Tuple of

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'
max_distance_from_linear(self, t0: float, t1: float) float

Compute the maximum distance from the nonlinear trajectory to a linearized trajectory

Parameters:
t0: float

Start time of the trajectory

t1: float

End time of the trajectory

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.

  1. __call__(self: ipctk.IntervalNonlinearTrajectory, t: float) -> numpy.ndarray[numpy.float64[m, 1]]

Compute the point’s position at time t

  1. __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.

Parameters:
t0: float

Start time of the trajectory

t1: float

End time of the trajectory

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

Miscellaneous

ipctk.point_static_plane_ccd(p_t0: numpy.ndarray[numpy.float64[m, 1]], p_t1: numpy.ndarray[numpy.float64[m, 1]], plane_origin: numpy.ndarray[numpy.float64[m, 1]], plane_normal: numpy.ndarray[numpy.float64[m, 1]], conservative_rescaling: float = 0.8) tuple[bool, float]

Compute the time of impact between a point and a static plane in 3D using continuous collision detection.

Parameters:
p_t0: numpy.ndarray[numpy.float64[m, 1]]

The initial position of the point.

p_t1: numpy.ndarray[numpy.float64[m, 1]]

The final position of the point.

plane_origin: numpy.ndarray[numpy.float64[m, 1]]

The origin of the plane.

plane_normal: numpy.ndarray[numpy.float64[m, 1]]

The normal of the plane.

conservative_rescaling: float = 0.8

Conservative rescaling of the time of impact.

Returns:

True if a collision was detected, false otherwise. Output time of impact

Return type:

Tuple of


Last update: Dec 12, 2024