pyvista.SolidSphere#
- SolidSphere(
- outer_radius: float = 0.5,
- inner_radius: float = 0.0,
- radius_resolution: int = 5,
- start_theta: float = 0.0,
- end_theta: float | None = None,
- theta_resolution: int = 30,
- start_phi: float = 0.0,
- end_phi: float | None = None,
- phi_resolution: int = 30,
- center: VectorLike[float] = (0.0, 0.0, 0.0),
- direction: VectorLike[float] = (0.0, 0.0, 1.0),
- radians: bool = False,
- tol_radius: float = 1e-08,
- tol_angle: float | None = None,
Create a solid sphere.
A solid sphere fills space in 3D in comparison to
pyvista.Sphere()
, which is a 2D surface.This function uses a linear sampling of each spherical coordinate, whereas
pyvista.SolidSphereGeneric()
allows for nonuniform 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) andphi
represents the polar angle (similar to degrees latitude on the globe). In contrast to latitude on the globe, herephi
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.While values for theta can be any value with a maximum span of 360 degrees, large magnitudes may result in problems with endpoint overlap detection.
- Parameters:
- outer_radius
float
, default: 0.5 Outer radius of sphere. Must be non-negative.
- inner_radius
float
, default: 0.0 Inner radius of sphere. Must be non-negative and smaller than
outer_radius
.- radius_resolution
int
, default: 5 Number of points in radial direction.
- start_theta
float
, default: 0.0 Starting azimuthal angle.
- end_theta
float
, default: 360.0 Ending azimuthal angle.
end_theta
must be greater thanstart_theta
.- theta_resolution
int
, default: 30 Number of points in
theta
direction.- start_phi
float
, default: 0.0 Starting polar angle.
phi
must lie between 0 and 180 in degrees.- end_phi
float
, default: 180.0 Ending polar angle.
phi
must lie between 0 and 180 in degrees.end_phi
must be greater thanstart_phi
.- phi_resolution
int
, default: 30 Number of points in
phi
direction, inclusive of polar axis, i.e.phi=0
andphi=180
in degrees, if applicable.- 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 fromcenter
to the sphere’s north pole at zero degreesphi
.- radiansbool, default:
False
Whether to use radians for
theta
andphi
. Default is degrees.- tol_radius
float
, default: 1.0e-8 Absolute tolerance for endpoint detection for
radius
.- tol_angle
float
,optional
Absolute tolerance for endpoint detection for
phi
andtheta
. Unit is determined by choice ofradians
parameter. Default is 1.0e-8 degrees or 1.0e-8 degrees converted to radians.
- outer_radius
- Returns:
pyvista.UnstructuredGrid
Solid sphere mesh.
See also
pyvista.Sphere
Sphere that describes outer 2D surface.
pyvista.SolidSphereGeneric
Uses more flexible parameter definition.
Examples
Create a solid sphere.
>>> import pyvista as pv >>> import numpy as np >>> solid_sphere = pv.SolidSphere() >>> solid_sphere.plot(show_edges=True)
A solid sphere is 3D in comparison to the 2d
pyvista.Sphere()
. Generate a solid hemisphere to see the internal structure.>>> isinstance(solid_sphere, pv.UnstructuredGrid) True >>> partial_solid_sphere = pv.SolidSphere(start_theta=180, end_theta=360) >>> partial_solid_sphere.plot(show_edges=True)
To see the cell structure inside the solid sphere, only 1/4 of the sphere is generated. The cells are exploded and colored by radial position.
>>> partial_solid_sphere = pv.SolidSphere( ... start_theta=180, ... end_theta=360, ... start_phi=0, ... end_phi=90, ... radius_resolution=5, ... theta_resolution=8, ... phi_resolution=8, ... ) >>> partial_solid_sphere['cell_radial_pos'] = np.linalg.norm( ... partial_solid_sphere.cell_centers().points, axis=-1 ... ) >>> partial_solid_sphere.explode(1).plot()