Scroll back to top

    Coordinate systems

    Cartesian coordinate system

    Cartesian coordinates (also known as rectangular coordinates) are the regular \(x,y\) or \(x,y,z\) coordinates in 2D and 3D, with perpendicular straight-line axes.

    coordinate name range definition
    \(x\) horizontal \(-\infty \lt x \lt \infty\) horizontal distance from the \(y\)-axis
    \(y\) vertical \(-\infty \lt y \lt \infty\) vertical distance from the \(x\)-axis

    In 3D the \(x\),\(y\),\(z\) axes are oriented in right-handed order, so that fingers curling from \(x\) to \(y\) means the thumb points in the \(z\) direction.

    Cartesian coordinate system, showing the origin \(O\) and three positions with their coordinates.

    Notation note

    When writing coordinates we can either list the coordinate values explicitly, like \(x = 2\), \(y = 1\), or we can just write the numbers in an ordered list, like \( (2, 1) \).

    Writing them as a list assumes that we know which coordinate system we are using, and which order the coordinates are in. We will typically write the coordinate values explicitly to avoid confusion. This also applies to vector components.

    Did you know?

    While the idea of \(x,y\) coordinates specifying positions might seem obvious, the use of algebraic quantities to define geometry in this way was a major discovery of René Descartes and a key event in the scientific revolution. Descartes was also instrumental in establishing the philosophical groundwork of The Enlightenment, and we owe to him the famous phrase Cogito ergo sum.

    Polar coordinate system

    Polar coordinates are an alternative 2D coordinate system that are useful for rotating or circular motion.

    coordinate name range definition
    \(r\) radius \(0 \le r \lt \infty\) distance from the origin \(O\)
    \(\theta\) angle \(-\pi \lt \theta \le \pi\) angle from the \(x\)-axis in the \(x\)–\(y\) plane

    The two common extensions of polar coordinates to 3D are cylindrical coordinates and spherical coordinates.

    Polar coordinate system, showing the origin \(O\) and three positions with their coordinates.

    To define polar coordinates, we relate them to another known coordinate system, typically Cartesian coordinates as follows, where we use the atan2 function.

    Conversion between polar and Cartesian coordinates #rvp-ep
    $$ \begin{aligned}x &= r \cos\theta& r &= \sqrt{x^2 + y^2} \\y &= r \sin\theta& \theta &= \operatorname{atan2}(y, x)\end{aligned} $$

    Did you know?

    Angles can be measured in many different units. While radians are the most mathematically elegant unit, their use dates only from Roger Cotes in the 18th century. Degrees are a much older unit, dating back to the sexagesimal number system of the ancient Babylonians, and are convenient for celestial calculations because there are approximately 360 days in one year. Other units include grads (100 grads in a right angle) and mils (various definitions, all approximately equal to a milliradian).

    Notation note

    When solving for \(\theta\) in terms of \(x\) and \(y\) we know that \(\tan\theta = y / x\). However, this does not necessary mean that \( \theta = \tan^{-1}(y / x) \), because \(\tan\) is not a one-to-one function. For example, \( \tan^{-1}(1/1) \) is the same as \( \tan^{-1}(-1/-1) \). We thus need to take \( \theta = \tan^{-1}(y/x) + \pi \) if the point is in quadrants II or III.

    An alternative is to use the atan2 function, which takes \(x\) and \(y\) as separate arguments and correctly handles the conversion to \(\theta\) in any quadrant. This function is available in all common programming languages, including C, MATLAB, Python, and others.

    Scientific calculators typically have special commands to convert to/from polar and Cartesian coordinates, which also automatically correctly handle the different quadrants.

    Spherical coordinates

    The spherical coordinate system extends polar coordinates into 3D by using an angle \(\phi\) for the third coordinate. This gives coordinates \((r, \theta, \phi)\) consisting of:

    coordinate name range definition
    \(r\) radius \(0 \le r \lt \infty\) distance from the origin
    \(\theta\) azimuth \(-\pi \lt \theta \le \pi\) angle from the \(x\)-axis in the \(x\)–\(y\) plane
    \(\phi\) inclination \(0 \le \phi \le \pi\) angle from the positive \(z\) axis

    The diagram below shows the spherical coordinates of a point \(P\). By changing the display options, we can see that the basis vectors are tangent to the corresponding coordinate lines. Changing \(\theta\) moves \(P\) along the \(\theta\) coordinate line in the direction \( \hat{e}_\theta \), and similarly for the other coordinates.

    Show:
    Coordinate lines:

    Radius:

    \(r = \; \) 4

    Azimuth:

    \(\theta = \; \) 45\(^\circ\)

    Inclination:

    \(\phi = \; \) 45°

    Spherical coordinates are defined with respect to a set of Cartesian coordinates, and can be converted to and from these coordinates using the atan2 function as follows.

    Conversion between spherical and Cartesian coordinates. #rvs-ec
    $$ \begin{aligned}x &= r \cos\theta \sin\phi & r &= \sqrt{x^2 + y^2 + z^2} \\y &= r \sin\theta \sin\phi & \theta &= \operatorname{atan2}(y, x) \\z &= r \cos\phi & \phi &= \operatorname{arccos}(z / r)\end{aligned} $$

    To find the conversion to Cartesian coordinates, we consider the projection of \( \vec{r} \) down onto the \(x\)–\(y\) plane, as shown. Then \(z = r \cos\phi\) and \( \ell = r \sin\phi \), from which we obtain \( x = \ell \cos\theta \) and \( y = \ell \sin\theta \).

    To convert from Cartesian coordinates, we use the same projection and read off the expressions for the spherical coordinates. This uses the atan2 function to handle the different quadrants for \(\theta\).

    The basis vectors are tangent to the coordinate lines and form an orthonormal basis \( \hat{e}_r, \hat{e}_\theta, \hat{e}_\phi \) that depends on the current position \(P\) as follows.

    Spherical basis vectors. #rvs-eb
    $$ \begin{aligned}\hat{e}_r &= \cos\theta \sin\phi \,\hat{\imath}+ \sin\theta \sin\phi \,\hat{\jmath} + \cos\phi \,\hat{k} \\\hat{e}_{\theta} &= - \sin\theta \,\hat{\imath}+ \cos\theta \,\hat{\jmath} \\\hat{e}_{\phi} &= \cos\theta \cos\phi \,\hat{\imath}+ \sin\theta \cos\phi \,\hat{\jmath} - \sin\phi \,\hat{k} \\[1em]\hat{\imath} &= \cos\theta \sin\phi \, \hat{e}_r- \sin\theta \, \hat{e}_\theta + \cos\theta \cos\phi \, \hat{e}_\phi \\\hat{\jmath} &= \sin\theta \sin\phi \, \hat{e}_r+ \cos\theta \, \hat{e}_\theta + \sin\theta \cos\phi \, \hat{e}_\phi \\\hat{k} &= \cos\phi \, \hat{e}_r - \sin\phi \, \hat{e}_\phi\end{aligned} $$

    We write the position vector \( \vec{r} = r \cos\theta \sin\phi \, \hat{\imath} + r \sin\theta \sin\phi \, \hat{\jmath} + r \cos\phi \, \hat{k} \) and then use the definition of coordinate basis vectors to find the non-normalized spherical basis vectors:

    $$ \begin{aligned} \vec{e}_r &= \frac{\partial\vec{r}}{\partial r} = \cos\theta \sin\phi \, \hat{\imath} + \sin\theta \sin\phi \, \hat{\jmath} + \cos\phi \, \hat{k} \\ \vec{e}_\theta &= \frac{\partial\vec{r}}{\partial\theta} = -r \sin\theta \sin\phi \, \hat{\imath} + r \cos\theta \sin\phi \, \hat{\jmath} \\ \vec{e}_\phi &= \frac{\partial\vec{r}}{\partial\phi} = r \cos\theta \cos\phi \, \hat{\imath} + r \sin\theta \cos\phi \, \hat{\jmath} - r \sin\phi \, \hat{k} \end{aligned} $$

    To normalize these vectors we divide by their lengths, which we can compute to be \( \| \vec{e}_r \| = 1 \), \( \| \vec{e}_\theta \| = r \sin\phi, and \| \vec{e}_\phi \| = r \).

    To invert the basis change we first observe that we can take combinations of \( \hat{e}_r \) and \( \hat{e}_{\phi} \) to give:

    $$ \begin{aligned} \cos\phi \, \hat{e}_r - \sin\phi \, \hat{e}_\phi &= \hat{k} \\ \sin\phi \, \hat{e}_r + \cos\phi \, \hat{e}_\phi &= \cos\theta \, \hat{\imath} + \sin\theta \, \hat{\jmath} \end{aligned} $$

    Then:

    $$ \begin{aligned} \cos\theta(\sin\phi \, \hat{e}_r + \cos\phi \, \hat{e}_\phi) - \sin\theta \, \hat{e}_\theta &= \cos^2\theta \, \hat{\imath} + \sin^2\theta \, \hat{\imath} = \hat{\imath} \\ \sin\theta(\sin\phi \, \hat{e}_r + \cos\phi \, \hat{e}_\phi) + \cos\theta \, \hat{e}_\theta &= \sin^2\theta \, \hat{\imath} + \cos^2\theta \, \hat{\jmath} = \hat{\jmath} \end{aligned} $$

    Rearranging these gives the Cartesian basis vector expressions above.

    Warning: \((\hat{e}_r,\hat{e}_\theta,\hat{e}_\phi)\) is not right-handed #rvs-wr

    Although it is common to write the spherical coordinates in the order \((r,\theta,\phi)\), this order gives a left-handed basis \( (\hat{e}_r,\hat{e}_\theta,\hat{e}_\phi) \), which we can see graphically from the fact that \( \hat{e}_r \times \hat{e}_\theta = -\hat{e}_\phi \). We can either work with this as a left-handed basis, or re-order the coordinates to give the right-handed basis \( (\hat{e}_r,\hat{e}_\phi,\hat{e}_\theta) \).

    If the spherical coordinates change with time then this causes the spherical basis vectors to rotate with the following angular velocity.

    Angular velocity of the spherical basis. #rvs-ew
    $$ \begin{aligned}\vec{\omega} &= \dot\phi \, \hat{e}_\theta + \dot\theta \, \hat{k} \\&= \dot\theta \cos\phi \,\hat{e}_r + \dot\phi \, \hat{e}_\theta- \dot\theta \sin\phi \,\hat{e}_{\phi}\end{aligned} $$

    Changing \(r\) does not cause a rotation of the basis, while changing \(\theta\) rotates about the vertical axis \( \hat{k} \) and changing \(\phi \) rotates about \( \hat{e}_\theta \). Combining these angular velocities gives the expression for \( \vec{\omega} \).

    The rotation of the basis vectors caused by changing coordinates can be directly computed, giving the time derivatives below.

    Time derivatives of spherical basis vectors. #rvs-et
    $$ \begin{aligned}\dot{\hat{e}}_r &= \dot\theta \sin\phi \,\hat{e}_{\theta}+ \dot\phi \,\hat{e}_{\phi} \\\dot{\hat{e}}_{\theta} &= - \dot\theta \sin\phi \,\hat{e}_r- \dot\theta \cos\phi \,\hat{e}_{\phi} \\\dot{\hat{e}}_{\phi} &= - \dot\phi \,\hat{e}_r+ \dot\theta \cos\phi \,\hat{e}_{\theta}\end{aligned} $$

    We can either directly differentiate the basis vector expressions, or we can recall that \( \dot{\hat{e}} = \vec{\omega} \times \hat{e} \) for any basis vector \( \hat{e} \). This gives:

    $$ \begin{aligned} \dot{\hat{e}}_r &= \vec{\omega} \times \hat{e}_r = \dot\theta \cos\phi \, \hat{e}_r \times \hat{e}_r + \dot\phi \, \hat{e}_\theta \times \hat{e}_r - \dot\theta \sin\phi \, \hat{e}_{\phi} \times \hat{e}_r \\ \dot{\hat{e}}_{\theta} &= \vec{\omega} \times \hat{e}_{\theta} = \dot\theta \cos\phi \,\hat{e}_r \times \hat{e}_\theta + \dot\phi \, \hat{e}_\theta \times \hat{e}_\theta - \dot\theta \sin\phi \,\hat{e}_{\phi} \times \hat{e}_\theta \\ \dot{\hat{e}}_{\phi} &= \vec{\omega} \times \hat{e}_{\phi} = \dot\theta \cos\phi \,\hat{e}_r \times \hat{e}_\phi + \dot\phi \, \hat{e}_\theta \times \hat{e}_\phi - \dot\theta \sin\phi \,\hat{e}_{\phi} \times \hat{e}_\phi \end{aligned} $$

    Now we evaluate the cross products graphically to obtain the final expressions.

    A point \(P\) at a time-varying position \((r,\theta,\phi)\) has position vector \( \vec{r} \), velocity \( \vec{v} = \dot{\vec{r}} \), and acceleration \( \vec{a} = \ddot{\vec{r}} \) given by the following expressions in spherical components.

    Position, velocity, and acceleration in spherical components. #rvs-ep
    $$ \begin{aligned}\vec{r} &= r \,\hat{e}_r \\\vec{v} &= \dot{r} \,\hat{e}_r+ r \dot\theta \sin\phi \,\hat{e}_{\theta}+ r \dot\phi \,\hat{e}_{\phi} \\\vec{a} &= (\ddot{r} - r \dot{\theta}^2 \sin^2\phi- r \dot{\phi}^2) \,\hat{e}_r \\&\quad + (r \ddot\theta \sin\phi+ 2 \dot{r} \dot\theta \sin\phi+ 2 r \dot\theta \dot\phi \cos\phi) \,\hat{e}_{\theta} \\&\quad + (r \ddot\phi + 2 \dot{r} \dot\phi- r \dot{\theta}^2 \sin\phi \cos\phi) \,\hat{e}_{\phi}\end{aligned} $$

    Because \( \hat{e}_r \) is a unit vector in the direction of the position vector \( \vec{r} \), we know that \( \vec{r} = r \, \hat{e}_r \). Then we can differentiate this expression to obtain:

    $$ \begin{aligned} \vec{v} &= \dot{\vec{r}} = \frac{d}{dt}\Big(r \, \hat{e}_r \Big) = \dot{r} \, \hat{e}_r + r \, \dot{\hat{e}}_r \end{aligned} $$

    and we substitute in the expression for \( \dot{\hat{e}_r} \)from above. Taking another derivative gives:

    $$ \begin{aligned} \vec{a} = \dot{\vec{v}} &= \frac{d}{dt}\Big( \dot{r} \,\hat{e}_r + r \dot\theta \sin\phi \,\hat{e}_{\theta} + r \dot\phi \,\hat{e}_{\phi} \Big) \\ &= \ddot{r} \, \hat{e}_r + \dot{r} \, \dot{\hat{e}}_r + (\dot{r} \dot\theta \sin\phi + r \ddot\theta \sin\phi + r \dot\theta \cos\phi \, \dot\phi) \, \hat{e}_\theta \\ &\quad + r \dot\theta \sin\phi \, \dot{\hat{e}}_\theta + (\dot{r} \dot\phi + r \ddot\phi) \, \hat{e}_\phi + r \dot\phi \, \dot{\hat{e}}_\phi \end{aligned} $$

    and again we can substitute the basis vector derivatives.

    Application alert!

    Shortest flight paths uses spherical coordinates.

    Spherical coordinates can be used to find the shortest flight path between two places on a globe.

    Cylindrical coordinates

    The cylindrical coordinate system extends polar coordinates into 3D by using the standard vertical coordinate \(z\) for the third. This gives coordinates \((r, \theta, z)\) consisting of:

    coordinate name range definition
    \(r\) radius \(0 \le r \lt \infty\) distance from the origin
    \(\theta\) azimuth \(-\pi \lt \theta \le \pi\) angle from the \(x\)-axis in the \(x\)–\(y\) plane
    \(z\) height \(-\infty \le z \le \infty\) vertical height

    The diagram below shows the cylindrical coordinates of a point \(P\). By changing the display options, we can see that the basis vectors are tangent to the corresponding coordinate lines. Changing \(\theta\) moves \(P\) along the \(\theta\) coordinate line in the direction \( \hat{e}_\theta \), and similarly for the other coordinates.

    Show:
    Coordinate lines:

    Radius:

    \(r = \; \) 4

    Azimuth:

    \(\theta = \; \) 45\(^\circ\)

    Elevation:

    \(z = \; \) 4

    Cylindrical coordinates are defined with respect to a set of Cartesian coordinates, and can be converted to and from these coordinates using the atan2 function, as described in the previos section of Spherical coordinates.

    The basis vectors are tangent to the coordinate lines and form an orthonormal basis \( \hat{e}_r, \hat{e}_\theta, \hat{e}_z \) that depends on the current position \( \vec{P} \) as follows. We can write either \( \hat{e}_z \) or \( \hat{k}_z \) for the vertical basis vector.

    Cylindrical basis vectors. #rvy-eb
    $$ \begin{aligned}\hat{e}_r &= \cos\theta \, \hat{\imath} + \sin\theta \,\hat{\jmath} \\\hat{e}_{\theta} &= - \sin\theta \,\hat{\imath}+ \cos\theta \,\hat{\jmath} \\\hat{e}_{z} &= \hat{k} \\[1em]\hat{\imath} &= \cos\theta \, \hat{e}_r- \sin\theta \, \hat{e}_\theta \\\hat{\jmath} &= \sin\theta \, \hat{e}_r+ \cos\theta \, \hat{e}_\theta \\\hat{k} &= \hat{e}_z \end{aligned} $$

    We write the position vector \( \vec{\rho} = r \cos\theta \, \hat{\imath} + r \sin\theta \, + z \, \hat{k} \) and then use the definition of coordinate basis vectors to find the non-normalized spherical basis vectors:

    $$ \begin{aligned} \vec{e}_r &= \frac{\partial\vec{\rho}}{\partial r} = \cos\theta \, \hat{\imath} + \sin\theta \, \hat{\jmath} \\ \vec{e}_\theta &= \frac{\partial\vec{\rho}}{\partial\theta} = -r \sin\theta \, \hat{\imath} + r \cos\theta \, \hat{\jmath} \\ \vec{e}_z &= \frac{\partial\vec{\rho}}{\partial\phi} = \hat{k} \end{aligned} $$

    Both \( \vec{e}_r \) and \( \vec{e}_z \) are already normalized, and the length \( \vec{e}_{\theta} \) is r, so we can divide by this to obtain the final normalized basis vector.

    To invert the basis change we can solve for \( \hat{\imath} \) and \( \hat{\jmath} \).

    If the cylindrical coordinates change with time then this causes the spherical basis vectors to rotate with the following angular velocity.

    Angular velocity of the cylindrical basis. #rvy-ew
    $$ \vec{\omega} = \dot\theta \, \hat{e}_z $$

    Changing \(r\) or \(z\) does not cause a rotation of the basis, while changing \(\theta\) rotates about the vertical axis \( \hat{e}_z \).

    The rotation of the basis vectors caused by changing coordinates gives the time derivatives below.

    Time derivatives of cylindrical basis vectors. #rvy-et
    $$ \begin{aligned}\dot{\hat{e}}_r &= \dot\theta \,\hat{e}_{\theta} \\\dot{\hat{e}}_{\theta} &= - \dot\theta \,\hat{e}_r\\\dot{\hat{e}}_z &= 0\end{aligned} $$

    We can either directly differentiate the basis vector expressions, or we can recall that \( \dot{\hat{e}} = \vec{\omega} \times \hat{e} \) for any basis vector \( \hat{e} \). This gives:

    $$ \begin{aligned} \dot{\hat{e}}_r &= \vec{\omega} \times \hat{e}_r = \dot\theta \, \hat{e}_z \times \hat{e}_r = \dot\theta \, \hat{e}_{\theta} \\ \dot{\hat{e}}_{\theta} &= \vec{\omega} \times \hat{e}_{\theta} = \dot\theta \, \hat{e}_z \times \hat{e}_{\theta} = -\dot\theta \, \hat{e}_r \\ \dot{\hat{e}}_{\phi} &= \vec{\omega} \times \hat{e}_{\phi} = \dot\theta \, \hat{e}_z \times \hat{e}_z = 0 \end{aligned} $$

    where we used the fact that \( \hat{e}_r , \hat{e}_{\theta} , \hat{e}_z \) form a right-handed orthonormal basis to evaluate the cross products.

    A point \(P\) at a time-varying position \((r,\theta, z)\) has position vector \( \vec{\rho} \), velocity \( \vec{v} = \dot{\vec{\rho}} \), and acceleration \( \vec{a} = \ddot{\vec{\rho}} \) given by the following expressions in cylindrical components.

    Position, velocity, and acceleration in cylindrical components. #rvy-ep
    $$ \begin{aligned}\vec{\rho} &= r \,\hat{e}_r +z \, \hat{e}_z \\\vec{v} &= \dot{r} \,\hat{e}_r+ r \dot\theta \,\hat{e}_{\theta}+ \dot{z} \,\hat{e}_{z} \\\vec{a} &= (\ddot{r} - r \dot{\theta}^2) \, \hat{e}_r + (r \ddot{\theta} + 2 \dot{r} \dot{\theta}) \, \hat{e}_{\theta} + \ddot{z} \, \hat{e}_z \end{aligned} $$

    From the coordinate expressions we see that the the position vector \( \vec{\rho} \), we know that \( \vec{\rho} = r \, \hat{e}_r + z \, \hat{e}_Z \). Differentiating this then gives:

    $$ \begin{aligned} \vec{v} &= \dot{\vec{\rho}} = \frac{d}{dt}\Big(r \, \hat{e}_r + z \, \hat{e}_z\Big) = \dot{r} \, \hat{e}_r + r \, \dot{\hat{e}}_r + \dot{z} \, \hat{e}_z + z \, \dot{\hat{e}}_z \end{aligned} $$

    and we substitute in the expression for \( \dot{\hat{e}_r} \) and \( \dot{\hat{e}_z} \) from above. Taking another derivative gives:

    $$ \begin{aligned} \vec{a} = \dot{\vec{v}} &= \frac{d}{dt}\Big( \dot{r} \,\hat{e}_r + r \dot\theta \,\hat{e}_{\theta} + \dot{z} \,\hat{e}_{z} \Big) \\ &= \ddot{r} \, \hat{e}_r + \dot{r} \, \dot{\hat{e}}_r + (\dot{r} \dot\theta + r \ddot\theta) \, \hat{e}_\theta + r \dot{\theta} \dot{\hat{e}_{\theta}} + \ddot{z} \hat{e}_z + \dot{z} \dot{\hat{e}_z} \\ \end{aligned} $$

    and again we can substitute the basis vector derivatives.

    Warning!

    We normally write \( \vec{r} \) for the position vector of a point, but if we are using cylindrical coordinates \( r,\theta ,z \) then this is dangerous. This is because \( r \) might mean the magnitude of \( \vec{r} \) or the radial coordinate, which are different. To avoid this confusion we use \( \vec{\rho} \) for the position vector and \( r \) for the radial coordinate.