pyvista.DataSet.bounding_sphere

pyvista.DataSet.bounding_sphere#

property DataSet.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.

Returns:
float, tuple

Sphere radius as a float and center as a tuple of floats.

Examples

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()
../../../_images/pyvista-DataSet-bounding_sphere-9e655949b24c2e6b_00_00.png