UniformGridFilters.compute_implicit_distance(surface, inplace=False)ΒΆ

Compute the implicit distance from the points to a surface.

This filter will compute the implicit distance from all of the nodes of this mesh to a given surface. This distance will be added as a point array called 'implicit_distance'.


The surface used to compute the distance.

inplacebool, optional

If True, a new scalar array will be added to the point_data of this mesh and the modified mesh will be returned. Otherwise a copy of this mesh is returned with that scalar field added.


Dataset containing the 'implicit_distance' array in point_data.


Compute the distance between all the points on a sphere and a plane.

>>> import pyvista as pv
>>> sphere = pv.Sphere()
>>> plane = pv.Plane()
>>> _ = sphere.compute_implicit_distance(plane, inplace=True)
>>> dist = sphere['implicit_distance']
>>> type(dist)
<class 'numpy.ndarray'>

Plot these distances as a heatmap

>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(sphere, scalars='implicit_distance', cmap='bwr')
>>> _ = pl.add_mesh(plane, color='w', style='wireframe')

See Clipping with a Surface and Voxelize a Surface Mesh for more examples using this filter.