colour.algebra.cartesian_to_spherical

colour.algebra.cartesian_to_spherical(a)[source]

Transforms given cartesian coordinates array \(xyz\) to spherical coordinates array \(\rho\theta\phi\) (radial distance, inclination or elevation and azimuth).

Parameters

a (array_like) – Cartesian coordinates array \(xyz\) to transform.

Returns

Spherical coordinates array \(\rho\theta\phi\), \(\rho\) is in range [0, +inf], \(\theta\) is in range [0, pi] radians, i.e. [0, 180] degrees, and \(\phi\) is in range [-pi, pi] radians, i.e. [-180, 180] degrees.

Return type

ndarray

References

[Wik06a], [Wik05b]

Examples

>>> a = np.array([3, 1, 6])
>>> cartesian_to_spherical(a)  
array([ 6.7823299...,  0.4850497...,  0.3217505...])