Compute the distance from a set of points to a mesh. Args: mesh (:class:`Mesh`): A input mesh. pts (:class:`numpy.ndarray`): A :math:`N \\times dim` array of query points. engine (``string``): BVH engine name. Valid choices are "cgal", "geogram",
(mesh, pts, engine="auto", bvh=None)
| 65 | |
| 66 | |
| 67 | def distance_to_mesh(mesh, pts, engine="auto", bvh=None): |
| 68 | """ Compute the distance from a set of points to a mesh. |
| 69 | |
| 70 | Args: |
| 71 | mesh (:class:`Mesh`): A input mesh. |
| 72 | pts (:class:`numpy.ndarray`): A :math:`N \\times dim` array of query |
| 73 | points. |
| 74 | engine (``string``): BVH engine name. Valid choices are "cgal", |
| 75 | "geogram", "igl" if all dependencies are used. The default is |
| 76 | "auto" where an available engine is automatically picked. |
| 77 | bvh (:class:`BVH`): BVH engine instance (optional) |
| 78 | |
| 79 | Returns: |
| 80 | Three values are returned. |
| 81 | |
| 82 | * ``squared_distances``: squared distances from each point to mesh. |
| 83 | * ``face_indices`` : the closest face to each point. |
| 84 | * ``closest_points``: the point on mesh that is closest to each |
| 85 | query point. |
| 86 | """ |
| 87 | |
| 88 | if not bvh: |
| 89 | bvh = BVH(engine, mesh.dim) |
| 90 | bvh.load_mesh(mesh) |
| 91 | squared_distances, face_indices, closest_points = bvh.lookup(pts) |
| 92 | return squared_distances, face_indices, closest_points |
| 93 | |
| 94 | def signed_distance_to_mesh(mesh, pts, engine="igl", bvh=None): |
| 95 | """ Compute the signed distance from a set of points to a mesh. |