# trimesh.intersections¶

## intersections.py¶

Primarily mesh-plane intersections (slicing).

Functions:

 `mesh_multiplane`(mesh, plane_origin, …) A utility function for slicing a mesh by multiple parallel planes which caches the dot product operation. `mesh_plane`(mesh, plane_normal, plane_origin) Find a the intersections between a mesh and a plane, returning a set of line segments on that plane. `plane_lines`(plane_origin, plane_normal, …) Calculate plane-line intersections `planes_lines`(plane_origins, plane_normals, …) Given one line per plane find the intersection points. `slice_faces_plane`(vertices, faces, …[, …]) Slice a mesh (given as a set of faces and vertices) with a plane, returning a new mesh (again as a set of faces and vertices) that is the portion of the original mesh to the positive normal side of the plane. `slice_mesh_plane`(mesh, plane_normal, …[, …]) Slice a mesh with a plane, returning a new mesh that is the portion of the original mesh to the positive normal side of the plane `windings_aligned`(triangles, normals_compare) Given a list of triangles and a list of normals determine if the two are aligned
`trimesh.intersections.``mesh_multiplane`(mesh, plane_origin, plane_normal, heights)

A utility function for slicing a mesh by multiple parallel planes which caches the dot product operation.

Parameters
• mesh (trimesh.Trimesh) – Geometry to be sliced by planes

• plane_normal ((3,) float) – Normal vector of plane

• plane_origin ((3,) float) – Point on a plane

• heights ((m,) float) – Offset distances from plane to slice at: at height=0 it will be exactly on the passed plane.

Returns

• lines ((m,) sequence of (n, 2, 2) float) – Lines in space for m planes

• to_3D ((m, 4, 4) float) – Transform to move each section back to 3D

• face_index ((m,) sequence of (n,) int) – Indexes of mesh.faces for each segment

`trimesh.intersections.``mesh_plane`(mesh, plane_normal, plane_origin, return_faces=False, cached_dots=None)

Find a the intersections between a mesh and a plane, returning a set of line segments on that plane.

Parameters
• mesh (Trimesh object) – Source mesh to slice

• plane_normal ((3,) float) – Normal vector of plane to intersect with mesh

• plane_origin ((3,) float) – Point on plane to intersect with mesh

• return_faces (bool) – If True return face index each line is from

• cached_dots ((n, 3) float) – If an external function has stored dot products pass them here to avoid recomputing

Returns

• lines ((m, 2, 3) float) – List of 3D line segments in space

• face_index ((m,) int) – Index of mesh.faces for each line Only returned if return_faces was True

`trimesh.intersections.``plane_lines`(plane_origin, plane_normal, endpoints, line_segments=True)

Calculate plane-line intersections

Parameters
• plane_origin ((3,) float) – Point on plane

• plane_normal ((3,) float) – Plane normal vector

• endpoints ((2, n, 3) float) – Points defining lines to be tested

• line_segments (bool) – If True, only returns intersections as valid if vertices from endpoints are on different sides of the plane.

Returns

• intersections ((m, 3) float) – Cartesian intersection points

• valid ((n, 3) bool) – Indicate whether a valid intersection exists for each input line segment

`trimesh.intersections.``planes_lines`(plane_origins, plane_normals, line_origins, line_directions, return_distance=False, return_denom=False)

Given one line per plane find the intersection points.

Parameters
• plane_origins ((n,3) float) – Point on each plane

• plane_normals ((n,3) float) – Normal vector of each plane

• line_origins ((n,3) float) – Point at origin of each line

• line_directions ((n,3) float) – Direction vector of each line

• return_distance (bool) – Return distance from origin to point also

• return_denom (bool) – Return denominator, so you can check for small values

Returns

• on_plane ((n,3) float) – Points on specified planes

• valid ((n,) bool) – Did plane intersect line or not

• distance ((n,) float) – [OPTIONAL] Distance from point

• denom ((n,) float) – [OPTIONAL] Denominator

`trimesh.intersections.``slice_faces_plane`(vertices, faces, plane_normal, plane_origin, cached_dots=None)

Slice a mesh (given as a set of faces and vertices) with a plane, returning a new mesh (again as a set of faces and vertices) that is the portion of the original mesh to the positive normal side of the plane.

Parameters
• vertices ((n, 3) float) – Vertices of source mesh to slice

• faces ((n, 3) int) – Faces of source mesh to slice

• plane_normal ((3,) float) – Normal vector of plane to intersect with mesh

• plane_origin ((3,) float) – Point on plane to intersect with mesh

• cached_dots ((n, 3) float) – If an external function has stored dot products pass them here to avoid recomputing

Returns

• new_vertices ((n, 3) float) – Vertices of sliced mesh

• new_faces ((n, 3) int) – Faces of sliced mesh

`trimesh.intersections.``slice_mesh_plane`(mesh, plane_normal, plane_origin, cap=False, cached_dots=None, **kwargs)

Slice a mesh with a plane, returning a new mesh that is the portion of the original mesh to the positive normal side of the plane

Parameters
• mesh (Trimesh object) – Source mesh to slice

• plane_normal ((3,) float) – Normal vector of plane to intersect with mesh

• plane_origin ((3,) float) – Point on plane to intersect with mesh

• cap (bool) – If True, cap the result with a triangulated polygon

• cached_dots ((n, 3) float) – If an external function has stored dot products pass them here to avoid recomputing

• kwargs (dict) – Passed to the newly created sliced mesh

Returns

new_mesh – Sliced mesh

Return type

Trimesh object