How to Convert One Spherical Coordinate System to Another?


BlogAdvanced AstrologyMathematics of the Celestial SphereSpherical Geometry
rotation matrices

Feb. 16, 2023, 3:32 a.m. Mark Rusborn 4 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 $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 \vec{X} + y \vec{Y} + z\vec{Z}$$

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

Rotation of the coordinate system

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

rotation of xy axes
Fig. 1 - Rotation of XY axes.

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

$$ \vec{v} = \grave{x} \vec{X_{rot}} + \grave{y} \vec{Y_{rot}} + \grave{z} \vec{Z_{rot}} $$

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

rotation of xy axes
Fig. 2 - a pointer to the x coordinate.

We can project this pointer (i.e., vector) to the $X_{rot}$ and $Y_{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:

$$ x \vec{X} = x \cos\alpha~ \vec{X_{rot}} - x \sin\alpha~ \vec{Y_{rot}} $$

In the same way

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

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

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

It means that:

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

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

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

Sine and cosine of two angles

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

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

rotation of xy axes
Fig. 3 - The sum of two angles.

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

If instead of $(x, y, z)$ notation, we use $(v_1, v_2, v_3)$ notation, we can write $(2)$ in the following form:

$$ \begin{cases} \grave{v_1} =& \cos\alpha~ v_1 &+ & \sin\alpha~v_2 &+& 0~v_3 \\\ \grave{v_2} = &-\sin\alpha~v_1 &+ &\cos\alpha~ v_2 &+& 0~v_3 \\\ \grave{v_3} =& 0~ v_1 &+ &0~ v_2 &+& 1~ v_3 \end{cases} $$

or even simpler:

$$ \grave{v_i} = \sum_{k=1}^3 A_{ik} v_k $$

where

$$\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}$ or $A_{ij}$ is the rotation matrix in the $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 $XZ$ and $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] $$

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

Multiplication of rotation matrices

If we need to rotate the coordinate system by the $\alpha$ angle in the $XY$ plane and then by the $\beta$ angle in the $\grave{X}\grave{Z}$ plane, we will apply two conversions in succession.

rotation of different axes
Fig. 4 - rotation in 2 steps.

First, we express the coordinates $v_i$ of the vector $\vec{v}$ in the coordinate system, rotated in the $XY$ plane.

$$ {v_i^\alpha} = \sum_{k=1}^3 A_{ik} v_k \\ \mathbf{A} = \left[\begin{array} {rrr} \cos\alpha & \sin\alpha & 0 \\ -\sin\alpha & \cos\alpha & 0 \\ 0 & 0 & 1 \end{array}\right] $$

Then we express ${v_i^\alpha}$ of the vector $\vec{v}$ in the coordinate system, rotated in the $XZ$ plane:

$$ {v_i^{\alpha\beta}} = \sum_{k=1}^3 B_{ik} v_k^\alpha \\ \mathbf{B} = \left[\begin{array} {rrr} \cos\beta & 0 & \sin\beta \\ 0 & 1 & 0 \\ -\sin\beta & 0 & \cos\beta \\ \end{array}\right] $$

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 $(x, y, z)$ coordinates by $(v_1, v_2, v_3)$

Step 2

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

$$ {\grave{v_i}} = \sum_{k,j=1}^3 B_{ij} A_{jk} v_k $$

Step 3

Finally, convert cartesian coordinates ${\grave{v_i}}$ to spherical angles with equation (2) from the previous article.


Mark Rusborn

Mark Rusborn

Search the Articles