Tutorials › Calculus III › Converting Points Between Cartesian And Spherical Coordinates

Cylindrical and Spherical Coordinates · Tutorial 283 of 999

Converting Points Between Cartesian And Spherical Coordinates

Calculate spherical coordinates from a Cartesian point, or Cartesian coordinates from a spherical triple, and verify that the chosen angles reproduce the point.

Intermediate 9 min read

What You'll Learn

  • Calculate the spherical radius from a point’s Cartesian coordinates.
  • Select the azimuth angle using the signs of the point’s horizontal coordinates.
  • Find the polar angle from the point’s height and distance from the z-axis.
  • Convert spherical coordinates to Cartesian coordinates and check the result.
  • Handle points on the z-axis and at the origin.

From a Point to Its Coordinates

A point in space can be described using Cartesian coordinates \((x,y,z)\) or spherical coordinates \((\rho,\theta,\phi)\). The spherical description records the point’s distance from the origin and its direction. To convert a point correctly, it is not enough to calculate the distance: the angles must also place the point in the correct direction.

We use the spherical convention in which \(\rho\) is the distance from the origin, \(\theta\) is the angle in the \(xy\)-plane measured from the positive \(x\)-axis, and \(\phi\) is measured down from the positive \(z\)-axis. The conversion formulas are

$$ x=\rho\sin(\phi)\cos(\theta),\qquad y=\rho\sin(\phi)\sin(\theta),\qquad z=\rho\cos(\phi). $$

For a standard choice of angles, take \(0\leq\theta<2\pi\) and \(0\leq\phi\leq\pi\). Angles are in radians. The order of the angles matters: in the triple \((\rho,\theta,\phi)\), \(\theta\) is the horizontal angle and \(\phi\) is the angle from the positive \(z\)-axis.

Definition: For a point \((x,y,z)\), its spherical radius is \(\rho=\sqrt{x^2+y^2+z^2}\). When \(\rho>0\), the polar angle \(\phi\) describes its inclination from the positive \(z\)-axis, and the azimuth angle \(\theta\) describes the direction of its projection into the \(xy\)-plane.

Converting Cartesian Coordinates to Spherical Coordinates

Begin with the radius, which is the distance from \((x,y,z)\) to the origin. To determine the azimuth, look at the point’s projection \((x,y)\) in the \(xy\)-plane. When \((x,y)\ne(0,0)\), its direction is specified by \(\cos(\theta)=x/\sqrt{x^2+y^2}\) and \(\sin(\theta)=y/\sqrt{x^2+y^2}\). Both signs matter; the angle must lie in the quadrant indicated by \(x\) and \(y\).

To determine \(\phi\), compare the point’s height \(z\) with its distance \(\rho\) from the origin. Since \(\cos(\phi)=z/\rho\), the choice \(0\leq\phi\leq\pi\) gives \(\phi=\arccos(z/\rho)\) when \(\rho>0\). An equivalent way to determine it is to use the horizontal distance \(s=\sqrt{x^2+y^2}\) and choose \(\phi\) with \(\sin(\phi)=s/\rho\) and \(\cos(\phi)=z/\rho\). Using both relations makes clear whether the point is above or below the \(xy\)-plane.

Conversion rule: For \((x,y,z)\ne(0,0,0)\), calculate \(\rho=\sqrt{x^2+y^2+z^2}\), choose \(\theta\) so that its cosine and sine have the directions of \(x\) and \(y\), and choose \(\phi\in[0,\pi]\) so that \(\cos(\phi)=z/\rho\). If \(x=y=0\), the azimuth does not affect the point; choose a convenient value such as \(\theta=0\).

A calculator’s ordinary inverse tangent can be misleading if used without checking the signs of \(x\) and \(y\). A two-argument inverse tangent, often written \(\operatorname{atan2}(y,x)\), uses both inputs to select the quadrant. If that function is unavailable, identify the quadrant first and then use a reference angle.

Worked Example: A Point in the Fourth Quadrant Above the Plane

Convert \((2,-2\sqrt{3},4)\) to spherical coordinates using \(0\leq\theta<2\pi\) and \(0\leq\phi\leq\pi\).

First calculate the radius:

$$ \rho=\sqrt{2^2+(-2\sqrt{3})^2+4^2} =\sqrt{4+12+16} =\sqrt{32} =4\sqrt{2}. $$

The horizontal coordinates satisfy \(x>0\) and \(y<0\), so the projection is in quadrant IV. Its reference angle has tangent \(\left|y/x\right|=\sqrt{3}\), hence it is \(\pi/3\). Therefore \(\theta=2\pi-\pi/3=5\pi/3\).

For the polar angle, \(\cos(\phi)=z/\rho=4/(4\sqrt{2})=\sqrt{2}/2\). Since \(z>0\), the point is above the \(xy\)-plane, and the angle in \([0,\pi]\) with this cosine is \(\phi=\pi/4\). Thus the spherical coordinates are \((4\sqrt{2},5\pi/3,\pi/4)\).

Check by converting back:

$$ x=4\sqrt{2}\cdot\frac{\sqrt{2}}{2}\cdot\frac{1}{2}=2, \qquad y=4\sqrt{2}\cdot\frac{\sqrt{2}}{2}\cdot\left(-\frac{\sqrt{3}}{2}\right)=-2\sqrt{3}, \qquad z=4\sqrt{2}\cdot\frac{\sqrt{2}}{2}=4. $$

The recovered coordinates match the original point.

Why the Inverse Calculations Work

The coordinate formulas themselves give a direct way to justify the conversion procedure. Let \(s=\sqrt{x^2+y^2}\) be the distance of the point’s projection from the origin in the \(xy\)-plane. Squaring the formulas for \(x\) and \(y\) and adding eliminates \(\theta\), because \(\cos^2(\theta)+\sin^2(\theta)=1\):

$$ x^2+y^2 =\rho^2\sin^2(\phi)\bigl(\cos^2(\theta)+\sin^2(\theta)\bigr) =\rho^2\sin^2(\phi). $$

With \(\rho\geq0\) and \(0\leq\phi\leq\pi\), this gives \(s=\rho\sin(\phi)\), while the third coordinate gives \(z=\rho\cos(\phi)\). Squaring and adding these two relations yields \(\rho^2=s^2+z^2=x^2+y^2+z^2\), which is exactly the radius formula. For \(\rho>0\), the ratios \(s/\rho\) and \(z/\rho\) determine \(\sin(\phi)\) and \(\cos(\phi)\). The horizontal coordinates determine \(\cos(\theta)=x/s\) and \(\sin(\theta)=y/s\) when \(s>0\). Choosing the angles from both sine and cosine information preserves their signs and therefore the point’s direction.

Converting Spherical Coordinates to Cartesian Coordinates

In the other direction, the calculation is direct: substitute the given values of \(\rho\), \(\theta\), and \(\phi\) into the three coordinate formulas. Keep track of which angle appears in each trigonometric factor. In particular, \(z\) uses \(\cos(\phi)\), while both horizontal coordinates use \(\sin(\phi)\).

Worked Example: Converting a Spherical Triple to Cartesian Coordinates

Convert \((5,\pi/6,2\pi/3)\) to Cartesian coordinates.

Here \(\rho=5\), \(\theta=\pi/6\), and \(\phi=2\pi/3\). Substitute these values:

$$ x=5\sin(2\pi/3)\cos(\pi/6) =5\cdot\frac{\sqrt{3}}{2}\cdot\frac{\sqrt{3}}{2} =\frac{15}{4}, $$
$$ y=5\sin(2\pi/3)\sin(\pi/6) =5\cdot\frac{\sqrt{3}}{2}\cdot\frac{1}{2} =\frac{5\sqrt{3}}{4}, $$
$$ z=5\cos(2\pi/3) =5\left(-\frac{1}{2}\right) =-\frac{5}{2}. $$

The Cartesian point is \((15/4,5\sqrt{3}/4,-5/2)\). To check its radius, calculate

$$ \sqrt{\left(\frac{15}{4}\right)^2+ \left(\frac{5\sqrt{3}}{4}\right)^2+ \left(-\frac{5}{2}\right)^2} = \sqrt{\frac{225}{16}+\frac{75}{16}+\frac{100}{16}} = \sqrt{25} =5. $$

The horizontal coordinates are both positive, and their ratio is \(y/x=\sqrt{3}/3\), consistent with \(\theta=\pi/6\). Also, \(z/\rho=-1/2=\cos(2\pi/3)\). These checks recover the given angles and radius.

Quadrant Selection and Special Cases

A correct radius and a plausible reference angle do not guarantee a correct conversion. For example, if \(x<0\) and \(y>0\), then the projection lies in quadrant II, so \(\theta\) must be between \(\pi/2\) and \(\pi\). In addition, the sign of \(z\) determines which half of the polar-angle range applies: \(z>0\) gives \(0\leq\phi<\pi/2\), \(z=0\) gives \(\phi=\pi/2\), and \(z<0\) gives \(\pi/2<\phi\leq\pi\), away from the axis endpoints.

On the \(z\)-axis, \(x=y=0\), so the point’s projection has no direction in the \(xy\)-plane. For a point above the origin on that axis, \(\phi=0\); below it, \(\phi=\pi\). Any value of \(\theta\) describes the same axis point, so a convenient choice such as \(0\) is sufficient. At the origin, \(\rho=0\), and the angles do not specify a direction; one may assign convenient angle values when a coordinate triple is required.

Worked Example: A Point Below the Origin in the \(xy\)-Plane

Convert \((-3,3,-3\sqrt{2})\) to spherical coordinates.

The radius is

$$ \rho=\sqrt{(-3)^2+3^2+(-3\sqrt{2})^2} =\sqrt{9+9+18} =\sqrt{36} =6. $$

Because \(x<0\) and \(y>0\), the projection lies in quadrant II. The absolute ratio is \(\left|y/x\right|=1\), so its reference angle is \(\pi/4\), giving \(\theta=3\pi/4\). Also, \(z/\rho=-3\sqrt{2}/6=-\sqrt{2}/2\). The polar angle in \([0,\pi]\) with this cosine is \(\phi=3\pi/4\). The triple is \((6,3\pi/4,3\pi/4)\).

Substitution verifies all three coordinates:

$$ x=6\cdot\frac{\sqrt{2}}{2}\cdot\left(-\frac{\sqrt{2}}{2}\right)=-3, \qquad y=6\cdot\frac{\sqrt{2}}{2}\cdot\frac{\sqrt{2}}{2}=3, \qquad z=6\left(-\frac{\sqrt{2}}{2}\right)=-3\sqrt{2}. $$

Each coordinate agrees with the starting point.

Worked Example: A Point on the Negative \(z\)-Axis

Convert \((0,0,-5)\) to spherical coordinates, choosing \(\theta=0\).

The radius is \(\rho=\sqrt{0^2+0^2+(-5)^2}=5\). Since \(z/\rho=-1\), choose \(\phi=\pi\). The azimuth can be chosen as \(\theta=0\), so one valid triple is \((5,0,\pi)\).

Check the conversion:

$$ x=5\sin(\pi)\cos(0)=0,\qquad y=5\sin(\pi)\sin(0)=0,\qquad z=5\cos(\pi)=-5. $$

The point is recovered. The azimuth choice was convenient rather than determined by the point.

A Common Mistake: Using the Tangent Ratio Alone

A frequent error is to calculate \(\theta=\arctan(y/x)\) and accept the calculator’s result without checking the quadrant. For \((-1,1,0)\), this shortcut gives \(\arctan(-1)=-\pi/4\). That angle points into quadrant IV, but the projection \((-1,1)\) is in quadrant II. The mistake comes from the tangent ratio alone: it cannot distinguish angles whose tangents are equal.

The reference angle is \(\pi/4\), and the quadrant is II, so the correct azimuth is \(\theta=3\pi/4\). The radius is \(\rho=\sqrt{1+1}=\sqrt{2}\), and \(z=0\) gives \(\phi=\pi/2\). Check the corrected triple:

$$ x=\sqrt{2}\sin(\pi/2)\cos(3\pi/4)=-1,\qquad y=\sqrt{2}\sin(\pi/2)\sin(3\pi/4)=1,\qquad z=\sqrt{2}\cos(\pi/2)=0. $$

The check confirms the quadrant-aware answer. Before accepting an angle, compare its sine and cosine signs with the coordinates that determine its direction.

A Reliable Conversion Checklist

1
Find the radius.
For a Cartesian point, calculate \(\rho=\sqrt{x^2+y^2+z^2}\). For a spherical triple, the radius is already given.
2
Choose the angles with signs in mind.
For Cartesian input, use the signs of \(x\) and \(y\) to locate \(\theta\), and use \(z/\rho\) to locate \(\phi\). For spherical input, substitute the supplied angles as written.
3
Substitute and verify.
Use the three coordinate formulas. For a Cartesian-to-spherical conversion, substitute the resulting triple back into those formulas and check that the original coordinates return.

These conversions are useful whenever a point is easier to describe by its distance and direction than by three separate Cartesian coordinates. The central habits are to keep the angle convention straight, choose the azimuth from the correct quadrant, and verify the resulting point by substitution.

Check Your Understanding

Use the stated convention \(0\leq\theta<2\pi\) and \(0\leq\phi\leq\pi\). For each conversion, show enough work to verify your answer.

  1. Convert \((0,4,0)\) to spherical coordinates.
  2. Convert \((3,\pi/2,\pi/2)\) to Cartesian coordinates.
  3. For \((-2,-2,2\sqrt{2})\), find \(\rho\), \(\theta\), and \(\phi\).
  4. Why is \(\arctan(y/x)\) alone not enough to select \(\theta\) in every quadrant?
  5. What is one valid spherical coordinate triple for the origin?