bluemira.codes.cgal_ext.collision_detection

Contains functions to efficiently convert to CGAL geometry and perform meshed-based collision detections.

Functions

_scale_points_from_centroid(points, scale_factor)

Scale a set of points from their centroid by a given scale factor.

tri_mesh_to_cgal_mesh(points, tris[, scale])

Convert a triangle mesh to a CGAL Polyhedron_3 object.

do_polys_collide(→ bool)

Check if two CGAL Polyhedron_3 objects collide.

Module Contents

bluemira.codes.cgal_ext.collision_detection._scale_points_from_centroid(points, scale_factor)

Scale a set of points from their centroid by a given scale factor.

Parameters:
  • points (np.ndarray) – An array of shape (n, 3) representing the x, y, z coordinates of the points.

  • scale_factor (float) – The scale factor by which to scale the points.

Returns:

scaled_points – An array of shape (n, 3) representing the scaled x, y, z coordinates of the points.

Return type:

np.ndarray

bluemira.codes.cgal_ext.collision_detection.tri_mesh_to_cgal_mesh(points: numpy.ndarray, tris: numpy.ndarray, scale: float = 1)

Convert a triangle mesh to a CGAL Polyhedron_3 object. This function is used to create a CGAL mesh from a set of points and triangles. It scales the points from their centroid by a given scale factor.

Parameters:
  • points (numpy.ndarray) – An array of shape (n, 3) representing the x, y, z coordinates of the points.

  • tris (numpy.ndarray) – An array of shape (m, 3) representing the indices of the points that form the triangles.

  • scale (float) – The scale factor by which to scale the points from their centroid.

Returns:

A CGAL Polyhedron_3 object representing the mesh.

Return type:

Polyhedron_3

Raises:

ImportError – If CGAL is not available, an ImportError is raised.

bluemira.codes.cgal_ext.collision_detection.do_polys_collide(mesh_a: CGAL.CGAL_Polyhedron_3.Polyhedron_3, mesh_b: CGAL.CGAL_Polyhedron_3.Polyhedron_3) bool

Check if two CGAL Polyhedron_3 objects collide.

Parameters:
  • mesh_a (CGAL.CGAL_Polyhedron_3.Polyhedron_3) – The first CGAL Polyhedron_3 object.

  • mesh_b (CGAL.CGAL_Polyhedron_3.Polyhedron_3) – The second CGAL Polyhedron_3 object.

Returns:

True if the two meshes collide, False otherwise.

Return type:

bool