capytaine.meshes.clip module

capytaine.meshes.clip.clip_faces(vertices: ndarray, faces: list[list[int]], normal: ndarray, origin: ndarray, tol: float = 1e-08) Tuple[ndarray, List[List[int]], ndarray][source]

Clip faces of a mesh against a plane.

The kept half-space is defined by (v - origin) · normal >= -tol.

Parameters:
  • vertices (numpy.ndarray) – Input vertex positions of shape (n, 3).

  • faces (list of list of int) – Face connectivity; triangles and quads are supported.

  • normal (numpy.ndarray) – Normal vector of the clipping plane.

  • origin (numpy.ndarray) – Point located on the plane.

  • tol (float, default=1e-8) – Tolerance for classifying vertices relative to the plane.

Returns:

  • np.ndarray of floats of shape (new_nb_vertices, 3) – The pruned vertex array

  • list of list of int – The list of of length new_nb_faces with clipped faces

  • np.ndarray of ints of shape (new_nb_faces,) – For each new face, the index of the face it comes from in the input.

capytaine.meshes.clip.compute_aspect_ratio(tri_pts: ndarray) float[source]

Compute the aspect ratio of a triangle.

The aspect ratio is defined as the longest edge length divided by the altitude relative to that edge.

Parameters:

tri_pts (numpy.ndarray) – Triangle vertices arranged in a (3, 3) array.

Returns:

Aspect ratio L / h (values greater than or equal to 1).

Return type:

float

Raises:

ValueError – If the triangle is degenerate and its area approaches zero.