compute_implicit_distance#
- StructuredGrid.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'
.- Parameters
- surface
pyvista.DataSet
The surface used to compute the distance.
- inplacebool,
optional
If
True
, a new scalar array will be added to thepoint_data
of this mesh and the modified mesh will be returned. Otherwise a copy of this mesh is returned with that scalar field added.
- surface
- Returns
pyvista.DataSet
Dataset containing the
'implicit_distance'
array inpoint_data
.
Examples
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') >>> pl.show()
See Clipping with a Surface and Voxelize a Surface Mesh for more examples using this filter.