Geometry Functionals#
- physicsnemo.nn.functional.signed_distance_field(
- mesh_vertices: Tensor,
- mesh_indices: Tensor,
- input_points: Tensor,
- max_dist: float = 100000000.0,
- use_sign_winding_number: bool = False,
Compute the signed distance field (SDF) for a mesh and query points.
The mesh must be a surface mesh consisting of triangles. This functional uses a Warp-backed implementation for accelerated execution.
- Parameters:
mesh_vertices (torch.Tensor) – Coordinates of mesh vertices with shape
(n_vertices, 3).mesh_indices (torch.Tensor) – Triangle connectivity indexing into
mesh_vertices. Expected shape is(n_faces, 3)or a flattened equivalent.input_points (torch.Tensor) – Query points at which to evaluate the signed distance, with shape
(..., 3).max_dist (float, optional) – Maximum search distance for closest-point queries. Default is
1e8.use_sign_winding_number (bool, optional) – Whether to use winding-number-based sign computation. Default is
False. WhenFalse, the mesh should be watertight for reliable signs.implementation (str, optional) – Explicit implementation name. Defaults to
None, which uses normal dispatch (currently the Warp implementation).
- Returns:
A tuple
(sdf, hit_points)where: -sdfcontains signed distances at each query point. -hit_pointscontains the closest point on the mesh for each query.- Return type:
tuple[torch.Tensor, torch.Tensor]
Examples
>>> mesh_vertices = torch.tensor( ... [(0.0, 0.0, 0.0), (1.0, 0.0, 0.0), (0.0, 1.0, 0.0)] ... ) >>> mesh_indices = torch.tensor([(0, 1, 2)]) >>> input_points = torch.tensor([(0.5, 0.5, 0.5)]) >>> sdf, hit_points = signed_distance_field( ... mesh_vertices, mesh_indices, input_points ... )