ImageData.bounding_sphere#
- property ImageData.bounding_sphere: tuple[float, tuple[float, float, float]][source]#
Compute the radius and center of a bounding sphere.
The sphere is exact for meshes with 4 points or less, and is otherwise approximated using Ritter’s algorithm. Returns NaN values if there are no points.
Uses vtkCell.ComputeBoundingSphere internally for the computation.
Added in version 0.48.
Examples#
Download Python source code | Download Jupyter notebook
Get the bounding sphere geometry of a mesh.
>>> import pyvista as pv
>>> from pyvista import examples
>>> mesh = examples.load_airplane()
>>> radius, center = mesh.bounding_sphere
Create a sphere and plot it along with the original mesh.
>>> sphere = pv.Icosphere(radius=radius, center=center)
>>> pl = pv.Plotter()
>>> _ = pl.add_mesh(mesh)
>>> _ = pl.add_mesh(sphere, style='wireframe', color='black')
>>> pl.view_xy()
>>> pl.camera.zoom(1.5)
>>> pl.show()