differt.geometry.triangle_mesh module#
Mesh geometry made of triangles and utilities.
- class TriangleMesh(vertices, triangles)[source]#
Bases:
Module
A simple geometry made of triangles.
- Parameters:
- property diffraction_edges: UInt[Array, 'num_edges 3']#
The diffraction edges.
- classmethod load_obj(file)[source]#
Load a triangle mesh from a Wavefront .obj file.
Currently, only vertices and triangles are loaded. Triangle normals are computed afterward (when first accessed).
- Parameters:
file (
str
) – The path to the Wavefront .obj file.- Return type:
- Returns:
The corresponding mesh containing only triangles.
- classmethod load_ply(file)[source]#
Load a triangle mesh from a Stanford PLY .ply file.
Currently, only vertices and triangles are loaded. Triangle normals are computed afterward (when first accessed).
- Parameters:
file (
str
) – The path to the Stanford PLY .ply file.- Return type:
- Returns:
The corresponding mesh containing only triangles.
- property normals: Float[Array, 'num_triangles 3']#
The triangle normals.
-
triangles:
UInt[Array, 'num_triangles 3']
# The array of triangle indices.
-
vertices:
Float[Array, 'num_vertices 3']
# The array of triangle vertices.
- paths_intersect_triangles(paths, triangle_vertices, epsilon=1e-06)[source]#
Return whether each path intersect with any of the triangles.
- Parameters:
paths (
Float[Array, '*batch path_length 3']
) – An array of ray paths of the same length.triangle_vertices (
Float[Array, 'num_triangles 3 3']
) – An array of triangle vertices.epsilon (
float
) – A small tolerance threshold that excludes a small portion of the path, to avoid indicating intersection when a path bounces off a triangle.
- Return type:
Bool[Array, '*batch']
- Returns:
A boolean array indicating whether vertices are in the corresponding triangles or not.
- triangles_contain_vertices_assuming_inside_same_plane(triangle_vertices, vertices)[source]#
Return whether each triangle contains the corresponding vertex, but assuming the vertex lies in the same plane as the triangle.
This is especially useful when combined with the
image_method
, as the paths returned will also lie in the same plane as the mirrors, but may be outside of the actual reflector, e.g., a triangular surface.- Parameters:
triangle_vertices (
Float[Array, '*batch 3 3']
) – an array of triangle vertices.vertices (
Float[Array, '*batch 3']
) – an array of vertices that will be checked.
- Return type:
Bool[Array, '*batch']
- Returns:
A boolean array indicating whether vertices are in the corresponding triangles or not.