Collision¤
compas_model.algorithms.collision
¤
Functions:¤
is_box_box_collision
¤
Determine whether two oriented boxes collide using separating axes.
is_brep_brep_collision
¤
is_brep_brep_collision(
A: Brep, B: Brep, tolerance: float = 0.0, include_touching: bool = True
) -> bool
Determine whether two COMPAS OCC BReps collide.
Parameters:
-
A(Brep) –The first BRep.
-
B(Brep) –The second BRep.
-
tolerance(float, default:0.0) –The maximum boundary separation considered a collision.
-
include_touching(bool, default:True) –If
True, boundary contact and solid containment are considered collisions. IfFalse, both BReps must be solids with positive common volume.
Returns:
-
bool–Trueif the BReps collide according to the selected semantics.
Raises:
-
ImportError–If the optional COMPAS OCC backend is unavailable.
-
TypeError–If either BRep does not use the COMPAS OCC backend.
-
ValueError–If
toleranceis negative or either BRep has an empty or invalid native shape. -
NotImplementedError–If touching is excluded for non-solids or with a positive tolerance.
-
RuntimeError–If Open CASCADE fails to complete the required query.
Notes
Default collision uses Open CASCADE's native shape-distance query. It
reports zero distance for boundary intersection and for one solid contained
in another. The comparison never uses less than Open CASCADE's own
Precision::Confusion() resolution. Excluding touching uses the volume
of the boolean intersection.
is_brep_brep_collision_fast
¤
is_brep_brep_collision_fast(
A: Brep, B: Brep, tolerance: float = 0.0, include_touching: bool = True
) -> bool
Conservatively test two BReps for collision using their AABBs.
Parameters:
-
A(Brep) –The first BRep.
-
B(Brep) –The second BRep.
-
tolerance(float, default:0.0) –The maximum AABB separation considered a collision.
-
include_touching(bool, default:True) –If
True, AABBs that only touch are considered colliding.
Returns:
-
bool–Falseguarantees that the BReps do not intersect.Truemeans that a more precise check may be required.
Raises:
-
ValueError–If either BRep exposes no points or
toleranceis negative.
Notes
Faces, edges, and analytic surfaces are not compared directly. Their extents are represented by the AABBs computed by the active COMPAS BRep backend, including extrema of curved geometry when supported by that backend.
is_mesh_mesh_collision
¤
is_mesh_mesh_collision(
A: Mesh, B: Mesh, tolerance: float = 0.0, include_touching: bool = True
) -> bool
Determine whether two mesh surfaces collide using Coal.
Parameters:
-
A(Mesh) –The first mesh.
-
B(Mesh) –The second mesh.
-
tolerance(float, default:0.0) –The maximum surface separation considered a collision.
-
include_touching(bool, default:True) –If
True, touching mesh surfaces are considered colliding.
Returns:
-
bool–Trueif the triangulated mesh surfaces intersect or are separated by no more thantolerance.
Raises:
-
ImportError–If the optional Coal backend is unavailable.
-
NotImplementedError–If
include_touchingisFalse. -
ValueError–If
toleranceis negative or a mesh cannot form a valid triangle collision model.
Notes
Mesh faces are triangulated without modifying the input meshes. Meshes are treated as surfaces, not implicitly as solids: one closed mesh entirely inside another does not collide unless their surfaces intersect.
Coal reports triangle contact but does not robustly distinguish all boundary-only contact from surface penetration. Excluding touching is therefore rejected instead of returning an ambiguous result.
is_mesh_mesh_collision_fast
¤
is_mesh_mesh_collision_fast(
A: Mesh, B: Mesh, tolerance: float = 0.0, include_touching: bool = True
) -> bool
Conservatively test two meshes for collision using their AABBs.
Parameters:
-
A(Mesh) –The first mesh.
-
B(Mesh) –The second mesh.
-
tolerance(float, default:0.0) –The maximum AABB separation considered a collision.
-
include_touching(bool, default:True) –If
True, AABBs that only touch are considered colliding.
Returns:
-
bool–Falseguarantees that the meshes do not intersect.Truemeans that a more precise check may be required.
Raises:
-
ValueError–If either mesh has no vertices or
toleranceis negative.
Notes
Mesh faces and topology are deliberately ignored. Therefore, overlapping AABBs can produce false positives but not false negatives, provided all mesh vertices bound the represented geometry.