sphere
Sphere
Sphere utility class.
cartesian_to_polar
classmethod
cartesian_to_polar(
x: ndarray | float, y: ndarray | float, z: ndarray | float
) -> Tuple[ndarray | float, ndarray | float, ndarray | float]
Convert the directional coordinates from cartesian to polar coordinate system.
integrate
classmethod
Integrate the directional coordinates over the sphere.
meshgrid
classmethod
Create a meshgrid for the spherical coordinates.
normalize
classmethod
Normalize the directional coordinates over the sphere.
polar_to_cartesian
classmethod
polar_to_cartesian(
theta: ndarray | float, phi: ndarray | float, radius: ndarray | float
) -> Tuple[ndarray | float, ndarray | float, ndarray | float]
Convert the directional coordinates from polar to cartesian coordinate system.
sample_uniform
classmethod
sample_uniform(
n_sample: int = N_SAMPLE_DEFAULT,
*,
csys: Literal["cartesian", "polar"] = "polar"
) -> Tuple[ndarray, ndarray, ndarray]
Sample uniformly on the unit sphere [1] [2].
PARAMETER | DESCRIPTION |
---|---|
n_sample
|
Number of samples, by default 1000.
TYPE:
|
csys
|
Coordinate system to use, by default "polar"
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[ndarray, ndarray, ndarray]
|
Tuple of theta, phi, and r coordinates in polar coordinates or x, y, and z coordinates in cartesian coordinates. |
References
.. [1] https://zhuanlan.zhihu.com/p/25988652 .. [2] https://pbr-book.org/3ed-2018/Monte_Carlo_Integration/2D_Sampling_with_Multidimensional_Transformations#UniformlySamplingaHemisphere
surface
classmethod
surface(
theta: ndarray,
phi: ndarray,
radius: ndarray,
*,
type: Literal["surface", "trisurf", "wireframe"] = "surface",
positive_color: str | None = None,
negative_color: str | None = None,
ax: Union["Axes3D", None] = None,
subplot_kwargs: dict | None = None,
**kwargs
) -> Tuple["Figure", "Axes3D"]
Plot the spherical coordinates.
PARAMETER | DESCRIPTION |
---|---|
theta
|
Meshgrid of theta, by default None.
TYPE:
|
phi
|
Meshgrid of phi, by default None.
TYPE:
|
radius
|
Meshgrid of radius, by default None.
TYPE:
|
type
|
Type of plot, by default "surface".
TYPE:
|
positive_color
|
Color for positive radius, by default None.
TYPE:
|
negative_color
|
Color for negative radius, by default None.
TYPE:
|
ax
|
Axes to plot on, by default None.
TYPE:
|
subplot_kwargs
|
Keyword arguments passed to
TYPE:
|
kwargs
|
Keyword arguments passed to
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
Tuple[Figure, Axes3D]
|
Tuple of the figure and the axes. |