How to Convert one Set of Spherical Coordinates to Another?


BlogMathematics of the Celestial SphereSpherical Geometry
rotation matrices

May 7, 2024, 9:10 p.m. Alexey Borealis 5 min. to read


In the previous article on basic trigonometry for astrologers, we derived formulas for converting spherical coordinates to Cartesian ones. In this article, we will get acquainted with the equations for the coordinate conversion from one spherical coordinate system to another. It will help us solve the previously stated task of converting ecliptic coordinates to equatorial, which is necessary for calculating primary directions.

[toc]

Cartesian Vector

First, we need to convert the spherical angles of the celestial object to cartesian coordinates with equation (2) from the previous article. We will perform all the conversions in cartesian coordinates.

For convenience, we introduce the idea of cartesian vector as a pointer to an object in the $\textbf{XYZ}$ coordinate system.

Vector has

  • starting point with coordinates $(0, 0, 0)$
  • endpoint with coordinates $(x, y, z)$ that coincides with the object's location.

We will denote the vector by the letter $\vec{v}$ and write its direction in the following form:

$$\vec{v} = x \textbf{X} + y \textbf{Y} + z\textbf{Z}$$

In the latter notation, we mean that the vector has an extent of $\textbf{X}$ units in the direction of the $\textbf{X}$-axis, an extent of $\textbf{Y}$ units along the $\textbf{Y}$-axis and the same for $\textbf{Z}$.

Rotation of the Coordinate System

What happens if we rotate the coordinate system by the angle $\alpha$ in $\textbf{XY}$ plane?

X Y α α x y y' x' X rot Y rot v

In the initial $\textbf{XYZ}$ system vector has coordinates $(x, y)$, but in a new (rotated) system, it has coordinates $(x^\prime, y^\prime, z^\prime)$, i.e.

$$ \vec{v} = x^\prime \textbf X_\text{rot} + y^\prime \textbf Y_\text{rot} + z^\prime \textbf Z_\text{rot} $$

Let's consider an $\textbf{X}$ part of the vector $\vec{v}$, namely, $x \textbf{X}$. It is a pointer to the $x$ coordinate.

α x Y rot X rot x cos(α) x sin(α)

We can project this pointer (i.e., vector) to the $\textbf X_\text{rot}$ and $\textbf Y_\text{rot}$ axes. We remember from (1) of the previous article that these projections are $x \cos\alpha$ and $-x \sin\alpha$. So we can write:

$$ х \textbf{X} = x \cos\alpha~ \textbf X_\text{rot} - x \sin\alpha~ \textbf Y_\text{rot} $$

In the same way

$$ y \textbf{Y} = y \sin\alpha~ \textbf X_\text{rot} + y \cos\alpha~ \textbf Y_\text{rot} $$

We do not change the $\textbf Z $-axis, so $z\textbf Z = z\textbf Z_\text{rot}$. Putting it all together, we have:

$$ \begin{aligned} \vec{v} &= \left(x \cos\alpha + y \sin\alpha\right) \textbf X_\text{rot} \\ &+ \left( -x \sin\alpha + y\cos\alpha \right) \textbf Y_\text{rot} \\ &+ z\textbf Z_\text{rot}\\ \vec{v} &= x^\prime \textbf X_\text{rot} + y^\prime \textbf Y_\text{rot} +z^\prime\textbf Z_\text{rot} \end{aligned} $$

It means that:

$$ \begin{cases} x^\prime = x\cos\alpha + y \sin\alpha \\ y^\prime = -x \sin\alpha + y\cos\alpha \\ z^\prime = z \end{cases}\tag{1} $$

For the reverse conversion we need to change $\alpha$ to $-\alpha$, which gives:

$$ \begin{cases} x = x^\prime\cos\alpha - y^\prime \sin\alpha \\ y = x^\prime \sin\alpha + y^\prime\cos\alpha \\ z = z^\prime \end{cases}\tag{2} $$

Sine and Cosine of Two Angles

From $(2)$, it follows a vital equation. Lets denote spherical longitude in $\textbf X_\text{rot} \textbf Y_\text{rot}$ plane by $\beta$, i.e.

$$ \begin{cases} x = \cos(\alpha + \beta) \\ y = \sin(\alpha + \beta) \\ x^\prime = \cos\beta \\ y^\prime = \sin\beta \\ \end{cases} $$

X Y α x y y' x' X rot Y rot v β

Then we immediately get the equations for the sine and cosine of the sum of two angles:

$$ \begin{aligned} &\cos(\alpha + \beta) = \cos\alpha\cos\beta - \sin\alpha\sin\beta \\\ &\sin(\alpha + \beta) = \sin\alpha\cos\beta + \sin\beta\cos\alpha \end{aligned}\tag{3} $$

Rotation Matrices

Let’s return to formula $(2)$. This time we write it more implicitly:

$$ \begin{cases}& x' = \cos\alpha &\times& x &+& \sin\alpha &\times& y &+& 0 &\times& z \\ & y' = -\sin\alpha &\times&x &+& \cos\alpha &\times& y &+& 0 &\times& z \\ & z' = 0 &\times& v &+& 0 &\times& y &+& 1 &\times& z\end{cases} $$

We have a repeating pattern — we sequentially multiply the $x$, $y$, and $z$ coordinates by specific coefficients in the first, second, and third rows and then sum the product of these multiplications.

We can separately list these coefficients of the 1st, 2nd, and 3rd rows in square brackets and express the same idea more concisely:

$$ \left(\begin{array}{r}x' \\\ y' \\\ z'\end{array}\right) = \left[\begin{array} {rrr} \cos\alpha & \sin\alpha & 0 \\\ -\sin\alpha & \cos\alpha & 0 \\\ 0 & 0 & 1 \end{array}\right] \times \left(\begin{array}{r}x \\\ y\\\ z\end{array}\right) $$

It is a more convenient representation of these three equations, but this compactness will make our lives easier. We pronounce it like this: If we multiply the coordinates $x$, $y$, and $z$ by these coefficients, then we will get the new coordinates of the vector in the coordinate system rotated at an angle $\alpha$.

These coefficients are commonly referred to as the rotation matrix, and the expression above is the multiplication of the coordinates $(x, y, z)$ by the rotation matrix, which gives new coordinates $(x’, y’, z’)$.

For rotation in the $\textbf{XY}$ plane on angle $\alpha$ we use the following matrix

$$\mathbf{A} = \left[\begin{array} {rrr} \cos\alpha & \sin\alpha & 0 \\ -\sin\alpha & \cos\alpha & 0 \\ 0 & 0 & 1 \end{array}\right]\tag{4} $$

$\mathbf{A}$ is the rotation matrix in the $\textbf{XY}$ plane, i.e., a 2-dimensional array of coefficients to be multiplied with coordinates.

For the inverse conversion, we change $\alpha$ to $-\alpha$, which gives an inverted matrix symmetrical to the original:

$$\mathbf{A^T} = \left[\begin{array} {rrr} \cos\alpha & -\sin\alpha & 0 \\ \sin\alpha & \cos\alpha & 0 \\ 0 & 0 & 1 \end{array}\right] $$

In the same way, the rotation matrices for rotation in $\textbf{XZ}$ and $\textbf{YZ}$ planes are:

$$\mathbf{A}_{XZ} = \left[\begin{array} {rrr} \cos\alpha & 0 & \sin\alpha \\\ 0 & 1 & 0 \\\ -\sin\alpha & 0 & \cos\alpha \end{array}\right]\tag{5} $$

$$\mathbf{A}_{YZ} = \left[\begin{array} {rrr} 1 & 0 & 0 \\ 0 & \cos\alpha & \sin\alpha \\ 0 & -\sin\alpha & \cos\alpha \end{array}\right] $$

Multiple Rotations

This concise notation for translating cartesian coordinates through rotation matrices gives us a significant advantage. Now, we can efficiently perform multiple sequential rotations in different planes and express them with a straightforward formula.

Suppose we want to rotate the coordinate system by an angle $\alpha$ along the $\textbf{XY}$ plane and then rotate the new coordinate system by an angle $\beta$ along the $\textbf X' \textbf Z'$ plane. First, we obtain the vector’s coordinates after rotation by angle $\alpha$:

$$ \left(\begin{array}{c}x'\\y'\\z'\end{array}\right) = \mathbf{A} \times \left(\begin{array}{c}x\\y\\z\end{array}\right) $$

Then we rotate this vector by angle $\beta$ in the second plane:

$$ \left(\begin{array}{c}x''\\y''\\z''\end{array}\right) = \mathbf{B} \times \left(\begin{array}{c}x'\\y'\\z'\end{array}\right) $$

We can express this even more simply:

$$ \left(\begin{array}{c}x''\\y''\\z''\end{array}\right) = \mathbf{B} \times \mathbf{A} \times \left(\begin{array}{c}x\\y\\z\end{array}\right) $$

As you can see, we simply multiply the matrices in the required sequence. Here, the first rotation matrix, according to $(4)$, is:

$$ \mathbf{A} = \left[ \begin{array}{rrr}\cos\alpha & \sin\alpha & 0 \\ -\sin\alpha & \cos\alpha & 0 \\ 0 & 0 & 1\end{array} \right] $$

And the second rotation matrix, according to $(5)$, is:

$$ \mathbf{B} = \left[ \begin{array}{rrr}\cos\beta & 0 & \sin\beta \\ 0 & 1 & 0 \\ -\sin\beta & 0 & \cos\beta \end{array} \right] $$

As you can see, we can write translations from one coordinate system to another very compactly.

Voila, we have coordinates of the initial vector in a new coordinate system. What we have to do eventually is to convert new cartesian coordinates into spherical angles in the rotated coordinate system.

To do this, we will use equation (2) from the previous article.

Bottom Line

You are now familiar with vector objects and rotation matrices.

You also know that the general approach to converting one spherical system to another consist of 3 steps.

Step 1

Covert spherical angles to cartesian coordinates with equation (2) from the previous article. We denote cartesian coordinates by $(x, y, z)$

Step 2

Rotate the coordinate system by angle $\alpha$ and then by $\beta$ and express cartesian coordinates in a new (rotated) system:

$$ \left(\begin{array}{c}x''\\y''\\z''\end{array}\right) = \mathbf{B} \times \mathbf{A} \times \left(\begin{array}{c}x\\y\\z\end{array}\right) $$

Step 3

Finally, convert cartesian coordinates $(x'', y'', z'')$ to spherical angles with equation (2) from the previous article.


Alexey Borealis

Alexey Borealis

Professional astrologer. About the author