- UniformGrid.find_closest_cell(point: Union[int, numpy.ndarray]) Union[int, numpy.ndarray] ¶
Find index of closest cell in this mesh to the given point.
Find nearest cell to a point on a sphere
>>> import pyvista >>> mesh = pyvista.Sphere() >>> index = mesh.find_closest_cell([0, 0, 0.5]) >>> index 59
Find the nearest cells to several random points. Note that
-1indicates that the locator was not able to find a reasonably close cell.
>>> import numpy as np >>> points = np.random.random((1000, 3)) >>> indices = mesh.find_closest_cell(points) >>> indices.shape (1000,)