When working on problems in three dimensional space it is often required convert between two or more co-ordinate systems. This article presents the formulae to convert between Cartesian and Spherical co-ordinate systems.


:Radial distance
:Zenith angle ()
:Azimuth angle ()


A common procedure when operating on 3D objects is the conversion between spherical and Cartesian co-ordinate systems. This is a rather simple operation however it often results in some confusion.

The spherical coordinates system defines a point in 3D space using three parameters, which may be described as follows:

  1. The radial distance from the origin (O) to the point (P), r.
  2. The zenith angle, between the zenith reference direction (z-axis) and the line OP with .
  3. The azimuth angle, between the azimuth reference direction (x-axis) and the orthogonal projection of the line OP of the reference plane (x-y plane) with .

Conversion from Cartesian to Spherical

Conversion Formula

We may convert a given a point in Cartesian co-ordinates (x,y,z) to spherical co-ordinates using the following formulas:

Notes on Computational Implementations

One must take care when implementing this conversion as using a standard atan function will only yield the correct spherical coordinates if the point is in the first or fourth quadrant (positive x values).

Instead the function atan2 should be used which takes the coordinates x and y as parameters and returns atan(y/x) taking into account the quadrant x and y lie in by adjusting the values as follows:

However take note of the parameter order of this function on your platform as it can differ. For example in C++ the interface is atan2(y,x) while in excel it is atan2(x,y).

Conversion from Spherical to Cartesian

Conversion Formula

Conversely spherical coordinates may be converted to Cartesian coordinates using the following formulas: