lagrange.bvh¶
Module Contents¶
Classes¶
Functions¶
|
Weld nearby vertices together of a surface mesh. |
- class lagrange.bvh.EdgeAABBTree2D(vertices, edges)¶
- Parameters:
vertices (Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 2), order='F')])
edges (Annotated[numpy.typing.NDArray[numpy.uint32], dict(shape=(None, 2), order='F')])
- empty()¶
Check if the tree is empty
- Return type:
bool
- get_closest_point(query_point)¶
Find the closest element and point within the element to the query point
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
- Returns:
A tuple containing: - The index of the closest element. - A NumPy array representing the closest point on the element. - The squared distance between the query point and the closest point.
- Return type:
tuple[int, Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order=’C’)], float]
- get_containing_elements(query_point)¶
Find all elements that contain the query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
- Returns:
A list of element indices that contain the query point.
- Return type:
list[int]
- get_element_closest_point(query_point, element_id)¶
Get the closest point on a specific edge.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
element_id (int) – Index of the edge to query.
- Returns:
A tuple containing: - A NumPy array representing the closest point on the edge. - The squared distance between the query point and the closest point.
- Return type:
tuple[Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order=’C’)], float]
- get_elements_in_radius(query_point, radius)¶
Find all elements within a given radius from a query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
radius (float) – Search radius.
- Returns:
A tuple containing: - A list of element indices within the specified radius. - A NumPy array of shape (N, 2) containing the closest points on each element.
- Return type:
tuple[list[int], Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 2), order=’C’, device=’cpu’)]]
- class lagrange.bvh.EdgeAABBTree3D(vertices, edges)¶
- Parameters:
vertices (Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 3), order='F')])
edges (Annotated[numpy.typing.NDArray[numpy.uint32], dict(shape=(None, 2), order='F')])
- empty()¶
Check if the tree is empty
- Return type:
bool
- get_closest_point(query_point)¶
Find the closest element and point within the element to the query point
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
- Returns:
A tuple containing: - The index of the closest element. - A NumPy array representing the closest point on the element. - The squared distance between the query point and the closest point.
- Return type:
tuple[int, Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order=’C’)], float]
- get_containing_elements(query_point)¶
Find all elements that contain the query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
- Returns:
A list of element indices that contain the query point.
- Return type:
list[int]
- get_element_closest_point(query_point, element_id)¶
Get the closest point on a specific edge.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
element_id (int) – Index of the edge to query.
- Returns:
A tuple containing: - A NumPy array representing the closest point on the edge. - The squared distance between the query point and the closest point.
- Return type:
tuple[Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order=’C’)], float]
- get_elements_in_radius(query_point, radius)¶
Find all elements within a given radius from a query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
radius (float) – Search radius.
- Returns:
A tuple containing: - A list of element indices within the specified radius. - A NumPy array of shape (N, 3) containing the closest points on each element.
- Return type:
tuple[list[int], Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 3), order=’C’, device=’cpu’)]]
- class lagrange.bvh.TriangleAABBTree2D(mesh)¶
- Parameters:
mesh (lagrange.core.SurfaceMesh)
- empty()¶
Check if the tree is empty
- Return type:
bool
- get_closest_point(query_point)¶
Find the closest element and point within the element to the query point
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
- Returns:
A tuple containing: - The index of the closest element. - A NumPy array representing the closest point on the element. - The squared distance between the query point and the closest point.
- Return type:
tuple[int, Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order=’C’)], float]
- get_elements_in_radius(query_point, radius)¶
Find all elements within a given radius from a query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=2, order='C', device='cpu')]) – Query point.
radius (float) – Search radius.
- Returns:
A tuple containing: - A list of element indices within the specified radius. - A NumPy array of shape (N, 2) containing the closest points on each element.
- Return type:
tuple[list[int], Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 2), order=’C’, device=’cpu’)]]
- class lagrange.bvh.TriangleAABBTree3D(mesh)¶
- Parameters:
mesh (lagrange.core.SurfaceMesh)
- empty()¶
Check if the tree is empty
- Return type:
bool
- get_closest_point(query_point)¶
Find the closest element and point within the element to the query point
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
- Returns:
A tuple containing: - The index of the closest element. - A NumPy array representing the closest point on the element. - The squared distance between the query point and the closest point.
- Return type:
tuple[int, Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order=’C’)], float]
- get_elements_in_radius(query_point, radius)¶
Find all elements within a given radius from a query point.
- Parameters:
query_point (list | Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=3, order='C', device='cpu')]) – Query point.
radius (float) – Search radius.
- Returns:
A tuple containing: - A list of element indices within the specified radius. - A NumPy array of shape (N, 3) containing the closest points on each element.
- Return type:
tuple[list[int], Annotated[numpy.typing.NDArray[numpy.float64], dict(shape=(None, 3), order=’C’, device=’cpu’)]]
- lagrange.bvh.weld_vertices(mesh, radius=9.999999974752427e-07, boundary_only=False)¶
Weld nearby vertices together of a surface mesh.
- Parameters:
mesh (lagrange.core.SurfaceMesh) – The target surface mesh to be welded in place.
radius (float) – The maximum distance between vertices to be considered for welding. Default is 1e-6.
boundary_only (bool) – If true, only boundary vertices will be considered for welding. Defaults to False.
- Return type:
None
Warning
This method may introduce non-manifoldness and degeneracy in the mesh.