pysdic.fem.triangle_3_cast_rays#
- triangle_3_cast_rays(vertices_coordinates, connectivity_array, ray_origins, ray_directions)[source]#
Compute the first intersection of rays with a 3D
triangle_3mesh.The intersected triangles are found with the ray casting scene of Open3D (in single precision), then the natural coordinates of the intersections are recomputed in double precision in these triangles. An intersection found by Open3D just outside its triangle (because of the single precision, for a ray passing close to an edge) is moved onto the edge of the triangle.
A ray is a half-line: only the intersections in the direction of the ray (\(t \geq 0\)) are found. Both sides of the triangles are intersected.
Note
Inputs
vertices_coordinates,ray_originsandray_directionswill be converted tonumpy.float64.Input
connectivity_arraywill be converted tonumpy.int64.
Important
Requires the optional package
open3d(pip install open3d).- Parameters:
vertices_coordinates (ArrayLike) – An array of shape \((N_v, 3)\) with the finite coordinates of the vertices.
connectivity_array (ArrayLike) – An array of shape \((N_e, 3)\) with the vertex indices of each triangle.
ray_origins (ArrayLike) – An array of shape \((N_r, 3)\) with the finite origins of the rays.
ray_directions (ArrayLike) – An array of shape \((N_r, 3)\) with the finite non-zero directions of the rays (not necessarily normalized).
- Returns:
natural_coordinates (numpy.ndarray) – An array of shape \((N_r, 2)\) with the natural coordinates \((\xi, \eta)\) of the intersections (NaN for the rays without intersection).
element_indices (numpy.ndarray) – An array of shape \((N_r,)\) with the index of the intersected triangle (
-1for the rays without intersection).
- Return type:
See also
pysdic.fem.cast_raysIntersection of rays with any surface mesh.
Examples
1import numpy 2from pysdic.fem import triangle_3_cast_rays 3 4vertices_coordinates = numpy.array([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]]) 5connectivity_array = numpy.array([[0, 1, 2], [0, 1, 3], [0, 2, 3], [1, 2, 3]]) 6 7ray_origins = numpy.array([[0.1, 0.2, -1.0], [2.0, 2.0, -1.0]]) 8ray_directions = numpy.array([[0.0, 0.0, 1.0], [0.0, 0.0, 1.0]]) 9 10natural_coordinates, element_indices = triangle_3_cast_rays( 11 vertices_coordinates, connectivity_array, ray_origins, ray_directions 12) 13print(natural_coordinates) 14print(element_indices)
[[0.1 0.2] [nan nan]] [ 0 -1]