mesh.Mesh.project_points#

Mesh.project_points(points, return_distances=False, return_indices=False)#

Project points onto a triangular surface mesh.

For each input point, this method computes the closest point on the surface of the mesh. The projected points are not restricted to mesh nodes and may lie anywhere on a triangle.

Parameters#

pointsfloat array_like with shape (N,3)

Coordinates of the points to project onto the mesh.

return_distancesbool, optional

If True, also return the Euclidean distance from each input point to its projected point on the mesh. Default is False.

return_indicesbool, optional

If True, also return the index of the triangle on which each projected point lies. Default is False.

Returns#

projectedcoords.Coords

Coordinates of the closest points on the mesh, with the same shape as the input points.

distancesfloat array, optional

Only returned if return_distances is True. Array containing the distance from each input point to its projection on the mesh.

indicesint array, optional

Only returned if return_indices is True. Array containing the index of the triangle on which each projected point lies.

Notes#

This method is currently implemented only for triangular surface meshes (tri3).

See Also#

coords.Coords.distance_to_points()

Examples#

>>> M = shapes.sphere()
>>> P = Coords([[2., 0., 0.], [0., 0., 0.]])
>>> Q, D = M.project_points(P, return_distances=True)
>>> D.shape
(2,)
>>> Q.shape == P.shape
True