Geometry on a Sphere
Contents
Plane geometry is familiar to us after we got through the life at junior middle school and senior high school. Spherical geometry, however, is a little difficult for us. Here, some topics, e.g., the great-circle distance, azimuth or back-azimuth will be introduced and implemented with the Python codes in the following sections.
1 The great-circle distance
Often, we calculate the great-circle distance of given two points in geophysics, for example, the distance from the seismic station to the epicenter. Supposing that we have two geographical points, and let’s say $P_1:\ (\phi_1, \lambda_1)$ and $P_2: \ (\phi_2, \lambda_2)$, where, $\phi$ and $\lambda$ represent the latitude and longitude, respectively. Using Haversine formula, we can calculate the great-circle distance.
$$
\left \{
\begin{aligned}
a &= sin^2(\frac{\Delta \phi}{2}) + cos\phi_1 \cdot cos\phi_2 \cdot sin^2(\frac{\Delta \lambda}{2}) \\
c &= 2 \cdot tan^{-1}(\frac{\sqrt{a}}{\sqrt{1-a}}) \text{ or } 2 \cdot sin^{-1}(\sqrt{a})\\
d &= c \cdot R
\end{aligned}
\right. \tag{1},
$$
where, $R$ is the average radius of our planet Earth, $\Delta \phi=\phi_2-\phi_1$ and $\Delta \lambda=\lambda_2-\lambda_1$. Here, we using the Python codes to give an example.
|
|
The implementation of finding the great-circle distance is in the Obspy library. We compare the results from above codes and the Obspy.
|
|
this: 1568.5205568
obspy: 1568.520556798576
$\color{red}{\text{One should note that we need to convert the degrees to radians} }$
$\color{red}{\text{ when we use trigonometric functions.}}$
2 The azimuth and back-azimuth
The azimuth or bearing is defined by the angle from the north to the great-circle arc of two geographical points. Here, we directly give the formula of calculating the azimuth $\theta$.
$$
\left \{
\begin{aligned}
y &= sin(\Delta \lambda) \cdot cos\phi_2 \\
x &= cos\phi_1 \cdot sin\phi_2 - sin\phi_1 \cdot cos\phi_2 \cdot cos(\Delta \lambda) \\
\alpha &= tan^{-1}\frac{y}{x} \\
\theta_a &= (\alpha \cdot 180 / \pi + 360) % 360
\end{aligned}
\right. \tag{2}.
$$
Exchange the order of $P_1$ and $P_2$ if one wants to calculate the back-azimuth $\theta_b$.
|
|
this: 44.5614514133
obspy: 44.56145141325769
3 The mid-point of two points
Now we suppose to find the mid-point $P_m: \ (\phi_m, \lambda_m)$ of the given two points, and this mid-point is defined as the half-way point along the great-circle arc between the given two points. The formula is given by
$$
\left \{
\begin{aligned}
b_x &= cos(\phi_2) \cdot cos(\Delta \lambda) \\
b_y &= cos(\phi_2) \cdot sin(\Delta \lambda) \\
\phi_m &= tan^{-1}(\frac{sin\phi_1+sin\phi_2}{\sqrt{(cos\phi_1+b_x)^2+b_y^2}})\\
\lambda_m &= \lambda_1 + tan^{-1}(\frac{b_y}{cos\phi_1+b_x})
\end{aligned}
\right. \tag{3}.
$$
|
|
5.01900069786 4.9616312267
Let’s check whether this result is reasonable or not. We set a function of calculating the great-circle distance first and use it to calculate the distances of the $P_m$ between $P_1$ and $P_2$, respectively. We also write a function of calculating the azimuth from the start point to the end point.
|
|
distance in km: 784.260278399 784.260278399
azimuth: 44.5614514133 44.7790409161
4 Intermediate point: the point on the great-circle arc with given fraction
An intermediate point $P_i: \ (\phi_i, \lambda_i)$ at arbitrary fraction $\alpha$ along the great circle path between the given two points can also be calculated. The formula is
$$
\left \{
\begin{aligned}
a &= \frac{ sin[(1-\alpha)\cdot\Delta] }{sin\Delta} \\
b &= \frac{ sin(\alpha \cdot \Delta) } {sin\Delta} \\
x &= a \cdot cos\phi_1 \cdot cos\lambda_1 + b \cdot cos \phi_2 \cdot cos\lambda_2 \\
y &= a \cdot cos\phi_1 \cdot sin\lambda_1 + b \cdot cos\phi_2 \cdot sin\lambda_2 \\
z &= a \cdot sin\phi_1 + b \cdot sin\phi_2\\
\phi_i &= tan^{-1}(\frac{z}{\sqrt{(x^2+y^2)}})\\
\lambda_i &= tan^{-1}(\frac{y}{x})
\end{aligned}
\right. \tag{4},
$$
where, $\Delta$ is the great-circle angular distance of the given two points $P_1$ and $P_2$.
Again, we write a function of calculating the intermediate point as below. The intermediate point is $P_1$ when $\alpha=0$ and $P_2$ when $\alpha=1$.
|
|
We set the fraction $\alpha=0.5$ that is the mid-point to verify our Python codes.
|
|
(5.0190006978611459, 4.9616312267025062)
5 Searching the destination point with given distance and azimuth
The destination which we term here, is the point when the great-circle distance and azimuth from the start point are given. This can be solved by
$$
\left \{
\begin{aligned}
\phi_d &= sin^{-1}(sin\phi_1\cdot cos\Delta+cos\phi_1 \cdot sin(\Delta) \cdot cos \theta_a) \\
\lambda_d &= \lambda_1 + tan^{-1}(\frac{sin\theta_a\cdot sin\Delta \cdot cos\phi_1} {cos\Delta-sin\phi_1\cdot sin\phi_d})
\end{aligned}
\right. \tag{5}.
$$
Here, we check our codes with the start point $P_1$, azimuth and the distance from $P_1$ to $P_2$.
|
|
(10.0, 10.0)
6 Intersection point of two great-circle paths when the start points and azimuths are given
Where is the intersection point $P_i: \ (\phi_i, \lambda_i)$ of two great-circle arcs when we have two start points and corresponding azimuth? First we convert the geographical point on a sphere to Cartecian coordinate according to
$$
P(\phi, \lambda) \rightarrow
\left [
\begin{array}{l}
& cos\phi \cdot cos\lambda \\
& cos\phi \cdot sin\lambda \\
& sin\phi
\end{array}
\right ] \tag{6},
$$
where, $\phi$ and $\lambda$ are latitude and longitude, respectively. With given the start point $\vec{a_0}$, azimuth $\theta_a$ and the great-circle angular distance $\Delta_a$, we can constrain the end point $\vec{a_1}$ on the great-circle arc. Similarly, we have the second great-circle arc according to these parameters: $\vec{b_0}$, $\theta_b$ and $\Delta_b$.
Let’s define two vectors,
$$
\left \{
\begin{aligned}
\vec{p} &= \vec{a_0} \times \vec{a_1} \\
\vec{q} &= \vec{b_0} \times \vec{b_1}
\end{aligned}
\right. \tag{7}.
$$
A new unit vector $\vec{t}$ defined as
$$
\vec{t} = \frac{\vec{p} \times \vec{q}}{|\vec{p} \times \vec{q}|} \tag{8}.
$$
Four scalars are given by
$$
\left \{
\begin{aligned}
s_1 &= \vec{a_0} \times \vec{p} \cdot \vec{t} \\
s_2 &= \vec{a_1} \times \vec{p} \cdot \vec{t} \\
s_3 &= \vec{b_0} \times \vec{q} \cdot \vec{t} \\
s_4 &= \vec{b_1} \times \vec{q} \cdot \vec{t}
\end{aligned}
\right. \tag{9},
$$
and we can find the intersection point by checking whether $-s_1, s_2, -s_3$ and $s_4$ are all the same sign. The last vector $\vec{t}$ is modified by
$$
\left \{
\begin{aligned}
\vec{t} &= \vec{t} \ \text{ if all the signs of the above four scalars are positive} \\
\vec{t} &= -\vec{t} \ \text{ if all the signs of the above four scalars are negative}
\end{aligned}
\right. \tag{10}.
$$
Let $x, y$ and $z$ be the components of the vector $t$, and the geographical information $(\phi, \lambda)$ of the intersection is given by
$$
\left \{
\begin{aligned}
\phi &= tan^{-1}(\frac{z}{\sqrt{x^2+y^2}}) \\
\lambda &= tan^{-1}(\frac{y}{x})
\end{aligned}
\right. \tag{11}
$$
The Python codes are
|
|
We give two start points $(0, 0), (0, -10)$, corresponding azimuths $180, 90$ degrees and great-circle angular distances $20$ degrees, and the intersection point is reasonably $(0, 0)$. Let’s check!
|
|
[ 6.09219391e-16 1.21843878e-15]
The result is not strictly $(0, 0)$, and this may be caused by the computation errors.
7 The cross-track distance
The cross-track distance is defined as the distance from a point to a great-circle arc, and this was used in our research about coda interferometry. We encountered a situation that we wanted to divide the large earthquakes into several groups according to the distances of the epicenters to the great-circle paths constrained by the station pairs in coda cross-correlations.
Therefore, the cross-track distance is a reasonable evaluation criteria, and it is given by $$ \Delta = |sin^{-1}[sin\Delta_{13}\cdot sin(\theta_{13}-\theta_{12})]|, \tag{12} $$
where $\Delta_{13}$ is the great-circle angular distance from $P_1$ to $P_3$, $\theta_{13}$ is the azimuth of $P_1$ to $P_3$ and $\theta_{12}$ $P_1$ to $P_2$.
Here, we set the first two geographical points $P_1:(0, -10),\ P_2:(0, 10)$ and the third point is $P_3:(10, 0)$. We know that the reasonable cross-track distance is $10$ degrees, and let’s verify that.
|
|
10.0
8 The closest point to the pole(s)
First give the latitude $\phi$ of the start point and azimuth $ \theta$, and the latitude on this great-circle path can be solved by $$ \phi_m=cos^{-1}(|sin\theta \cdot cos\phi|) \tag{13}, $$ and this can derived from Clairaut’s formula.
Bibliography
http://www.movable-type.co.uk/scripts/latlong.html
https://enrico.spinielli.net/2014/10/19/understanding-great-circle-arcs_57/
Author Geophydog
LastMod 2021-03-02