pyvista.SolidSphereGeneric#

SolidSphereGeneric(radius=None, theta=None, phi=None, center=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 1.0), radians=False, tol_radius=1e-08, tol_angle=None)[source]#

Create a solid sphere with flexible sampling.

A solid sphere fills space in 3D in comparison to pyvista.Sphere(), which is a 2D surface.

This function allows user defined sampling of each spherical coordinate, whereas pyvista.SolidSphere() only allows linear sampling. Angles are by default specified in degrees.

PyVista uses a convention where theta represents the azimuthal angle (similar to degrees longitude on the globe) and phi represents the polar angle (similar to degrees latitude on the globe). In contrast to latitude on the globe, here phi is 0 degrees at the North Pole and 180 degrees at the South Pole. phi=0 is on the positive z-axis by default. theta=0 is on the positive x-axis by default.

Parameters:
radiussequence[float], optional

A monotonically increasing sequence of values specifying radial points. Must have at least two points and be non-negative.

thetasequence[float], optional

A monotonically increasing sequence of values specifying theta points. Must have at least two points. Can have any value as long as range is within 360 degrees. Large magnitudes may result in problems with endpoint overlap detection.

phisequence[float], optional

A monotonically increasing sequence of values specifying phi points. Must have at least two points. Must be between 0 and 180 degrees.

centersequence[float], default: (0.0, 0.0, 0.0)

Center coordinate vector in [x, y, z].

directionsequence[float], default: (0.0, 0.0, 1.0)

Direction coordinate vector in [x, y, z] pointing from center to the sphere’s north pole at zero degrees phi.

radiansbool, default: False

Whether to use radians for theta and phi. Default is degrees.

tol_radiusfloat, default: 1.0e-8

Absolute tolerance for endpoint detection for radius.

tol_anglefloat, optional

Absolute tolerance for endpoint detection for phi and theta. Unit is determined by choice of radians parameter. Default is 1.0e-8 degrees or 1.0e-8 degrees converted to radians.

Returns:
pyvista.UnstructuredGrid

Solid sphere mesh.

See also

pyvista.SolidSphere

Sphere creation using linear sampling.

pyvista.Sphere

Sphere that describes outer 2D surface.

Examples

Linearly sampling spherical coordinates does not lead to cells of all the same size at each radial position. Cells near the poles have smaller sizes.

>>> import pyvista as pv
>>> import numpy as np
>>> solid_sphere = pv.SolidSphereGeneric(
...     radius=np.linspace(0, 0.5, 2),
...     theta=np.linspace(180, 360, 30),
...     phi=np.linspace(0, 180, 30),
... )
>>> solid_sphere = solid_sphere.compute_cell_sizes()
>>> solid_sphere.plot(
...     scalars="Volume", show_edges=True, clim=[3e-5, 5e-4]
... )
../../../_images/pyvista-SolidSphereGeneric-1_00_00.png

Sampling the polar angle in a nonlinear manner allows for consistent cell volumes. See Sphere Point Picking.

>>> phi = np.rad2deg(np.arccos(np.linspace(1, -1, 30)))
>>> solid_sphere = pv.SolidSphereGeneric(
...     radius=np.linspace(0, 0.5, 2),
...     theta=np.linspace(180, 360, 30),
...     phi=phi,
... )
>>> solid_sphere = solid_sphere.compute_cell_sizes()
>>> solid_sphere.plot(
...     scalars="Volume", show_edges=True, clim=[3e-5, 5e-4]
... )
../../../_images/pyvista-SolidSphereGeneric-1_01_00.png