pyvista.cartesian_to_spherical#
- cartesian_to_spherical(x, y, z)[source]#
Convert 3D Cartesian coordinates to spherical coordinates.
- Parameters:
- x, y, z
numpy.ndarray
Cartesian coordinates.
- x, y, z
- Returns:
- r
numpy.ndarray
Radial distance.
- phi
numpy.ndarray
Angle (radians) with respect to the polar axis. Also known as polar angle.
- theta
numpy.ndarray
Angle (radians) of rotation from the initial meridian plane. Also known as azimuthal angle.
- r
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)