Cartesian to Spherical Coordinates Converter

Cartesian to Spherical Coordinates Converter

Growing AI Skill PRO

Enter Calculation

Formula

r=x2+y2+z2θ=atan2(y,x)·180π,φ=atan2(x2+y2,z)·180πwhere{x=xy=yz=z\begin{gathered} r = \sqrt{x^2 + y^2 + z^2} \\[0.6em] \theta = \operatorname{atan2}(y,\, x)\cdot\frac{180}{\pi}, \quad \varphi = \operatorname{atan2}\!\left(\sqrt{x^2+y^2},\, z\right)\cdot\frac{180}{\pi} \\[1.5em] \text{where}\quad \left\{ \begin{aligned} x &= \text{x} \\ y &= \text{y} \\ z &= \text{z} \end{aligned} \right. \end{gathered}
Usage stats

Advertisement

Results

Radial distance r
7.071068
spherical coordinates (r, θ, φ)
θ (azimuth) 53.130102 deg
φ (inclination) 45 deg

Report an error on this page

What this converter does

This tool converts a point given in 3D Cartesian coordinates (x, y, z) into spherical coordinates (r, theta, phi). It is a pure-mathematics tool that works for any real input values and lets you choose whether the two angles are reported in degrees or radians.

The convention used here

Follow this page's convention exactly, as it can differ from other textbooks. Here r is the radial distance from the origin, theta is the azimuthal angle measured in the x-y plane from the positive x-axis, and phi is the polar (inclination) angle measured down from the positive z-axis.

3D diagram showing point P with radius r, polar angle phi from z-axis, and azimuth theta in the xy-plane
Spherical coordinates: r is the distance to the origin, phi is measured from the z-axis, and theta is the azimuth in the xy-plane.

The formulas

$$r = \sqrt{x^2 + y^2 + z^2}$$ The angles use the two-argument arctangent for robustness: $$\theta = \operatorname{atan2}(y,\, x) \quad\text{and}\quad \varphi = \operatorname{atan2}\!\left(\sqrt{x^2 + y^2},\, z\right)$$ Using \(\operatorname{atan2}\) instead of the naive \(\arctan(y/x)\) avoids division-by-zero and keeps the correct quadrant. All trig results are in radians; when "Degrees" is selected, each angle is multiplied by \(\frac{180}{\pi}\).

Advertisement
Right-triangle diagram relating r, z, the planar distance, and the angles phi and theta
The formulas come from right triangles: phi relates z to r, while theta is fixed by x and y.

How to use it

Enter the x, y and z components of your point, pick the output angle unit, and read off r, theta and phi. r is independent of the chosen angle unit.

Worked example

For \(x = 3\), \(y = 4\), \(z = 5\) in degrees: $$r = \sqrt{9 + 16 + 25} = \sqrt{50} = 7.071068$$ $$\theta = \operatorname{atan2}(4, 3) = 0.927295 \text{ rad} = 53.130102^\circ$$ With \(\sqrt{x^2+y^2} = \sqrt{25} = 5\), $$\varphi = \operatorname{atan2}(5, 5) = \arctan(1) = 0.785398 \text{ rad} = 45^\circ$$

Common Points and Their Spherical Coordinates

This page uses \(r=\sqrt{x^2+y^2+z^2}\), \(\theta=\operatorname{atan2}(y,x)\) (azimuth, measured in the xy-plane from the +x axis) and \(\varphi=\operatorname{atan2}\left(\sqrt{x^2+y^2},\,z\right)\) (polar angle, measured from the +z axis).

Cartesian (x, y, z) r θ (degrees) θ (radians) φ (degrees) φ (radians)
(1, 0, 0) 1 0° 0 90° 1.5708 (π/2)
(0, 1, 0) 1 90° 1.5708 (π/2) 90° 1.5708 (π/2)
(−1, 0, 0) 1 180° 3.1416 (π) 90° 1.5708 (π/2)
(0, −1, 0) 1 −90° −1.5708 (−π/2) 90° 1.5708 (π/2)
(0, 0, 1) 1 0° (undefined, reported as 0) 0 0° 0
(0, 0, −1) 1 0° (undefined, reported as 0) 0 180° 3.1416 (π)
(1, 1, 0) √2 ≈ 1.414214 45° 0.7854 (π/4) 90° 1.5708 (π/2)
(1, 1, 1) √3 ≈ 1.732051 45° 0.7854 (π/4) 54.7356° 0.955317
(0, 0, 0) 0 0° (undefined, reported as 0) 0 0° (undefined, reported as 0) 0

Ranges from atan2: θ lies in (−180°, 180°] (that is, (−π, π]) and φ lies in [0°, 180°] (that is, [0, π]).

Advertisement

Convention Comparison and Angle Unit Conversion

Different books and software use the names θ and φ differently, so always check which angle a source means before comparing numbers.

Convention θ means φ means Notes
This page (common in mathematics texts) Azimuth, from +x in the xy-plane, via atan2(y, x) Polar angle, from +z axis, range 0° to 180° Used by this calculator
Common physics convention (ISO 80000-2) Polar angle, from +z axis Azimuth, from +x in the xy-plane θ and φ are swapped relative to this page
Geography (latitude/longitude) Longitude = azimuth Latitude = 90° − polar angle Latitude ranges from −90° to 90°

Reverse formulas (this page's naming)

$$x = r\sin\varphi\cos\theta,\qquad y = r\sin\varphi\sin\theta,\qquad z = r\cos\varphi$$

Degrees and radians

Degrees Radians (exact) Radians (decimal)
30° π/6 0.5236
45° π/4 0.7854
60° π/3 1.0472
90° π/2 1.5708
180° π 3.1416
270° 3π/2 4.7124
360° 2π 6.2832

Conversion: \(\text{radians} = \text{degrees}\times\pi/180\). If you prefer θ in [0°, 360°), add 360° (or 2π) to any negative θ.

Interpreting Your Result

  • r is the straight-line distance from the origin, so it is always ≥ 0.
  • θ (azimuth) comes from atan2(y, x) and lies in (−180°, 180°]. A negative θ means y < 0; add 360° to get a value in the 0°–360° range.
  • φ (polar angle) lies in [0°, 180°]. If φ < 90°, then z > 0 (upper hemisphere). If φ = 90°, then z = 0 (the point is in the xy-plane). If φ > 90°, then z < 0 (lower hemisphere).
  • Undefined cases: on the z-axis (x = 0 and y = 0) θ is undefined, and at the origin both angles are undefined. The calculator reports 0 for undefined angles by the atan2(0, 0) convention.

Quadrant to θ range

Signs of x, y Location θ (atan2 range) θ (0°–360° range)
x > 0, y > 0 Quadrant I 0° to 90° 0° to 90°
x < 0, y > 0 Quadrant II 90° to 180° 90° to 180°
x < 0, y < 0 Quadrant III −180° to −90° 180° to 270°
x > 0, y < 0 Quadrant IV −90° to 0° 270° to 360°

On the axes: +x gives 0°, +y gives 90°, −x gives 180°, and −y gives −90° (270°).

FAQ

What happens when x = 0? \(\operatorname{atan2}\) handles it cleanly: \(x = 0\) with \(y > 0\) gives \(\theta = 90^\circ\), and \(y < 0\) gives \(\theta = -90^\circ\).

What if z = 0? The point lies in the x-y plane, so \(\varphi = 90^\circ\) (\(\pi/2\)). A \(z < 0\) correctly yields phi greater than 90 deg.

What about the origin? If \(x = y = z = 0\) then \(r = 0\) and the angles are mathematically undefined; this tool reports 0 for both by \(\operatorname{atan2}\) convention.

Last updated:

Most popular in Math and Statistics

View all Math and Statistics calculators