pyvista.cartesian_to_spherical#

cartesian_to_spherical(x, y, z)[source]#

Convert 3D Cartesian coordinates to spherical coordinates.

Parameters:
x, y, znumpy.ndarray

Cartesian coordinates.

Returns:
rnumpy.ndarray

Radial distance.

phinumpy.ndarray

Angle (radians) with respect to the polar axis. Also known as polar angle.

thetanumpy.ndarray

Angle (radians) of rotation from the initial meridian plane. Also known as azimuthal angle.

Examples

>>> import numpy as np
>>> import pyvista as pv
>>> grid = pv.ImageData(dimensions=(3, 3, 3))
>>> x, y, z = grid.points.T
>>> r, phi, theta = pv.cartesian_to_spherical(x, y, z)