Suppose I have a point $P$ on a unit sphere whose spherical coordinates are $(\theta, \varphi)$, and a great arc from point $Q$ to point $R$, also specified in spherical coordinates. I want to find the minimum distance (great arc distance, preferably) between the point and the arc. Can somebody help me on that?

My best guess would be to take the formula for the Great arc distance between two points on a unit sphere, plug in a point $S$ parameterized by $t$ on the arc between $Q$ and $R$, and find the minimum distance between $P$ and $S$. But I would definitely need help with that.


2 Answers 2


Consider the full great circle that your $Q$ to $R$ arc is part of. There are two points (poles) which are each 90 degrees of arc from every point on the great circle. (You can find these points by forming a 90-90-x triangle from your arc segment.) Choosing the point which is on the same hemisphere as your point $P$, there is an arc from this pole, through $P$, to the great circle. Since the length of this arc is 90 degrees, the distance from $P$ to the great circle is the complement of the distance from the pole to $P$.

Determining the distance from $P$ to the actual arc then is just a matter of determining if the intersection point is between $Q$ and $R$, and if not, determining the distances from $P$ to $Q$ and $R$ to get the minimum.

A note to anyone who objects to my use of degrees: sorry, but I use my spherical trig on the actual earth, where lat and long are still measured in degrees. And yes, I am aware it is not a true sphere, but that is a separate topic.

  • $\begingroup$ Thanks, this makes a lot of sense. Let me see if I can work out all the details. $\endgroup$
    – LarsH
    Commented Mar 21, 2013 at 23:56
  • $\begingroup$ P.S. funny that you're a geographer... I was debating whether I should ask this question on gis.stackexchange.com. $\endgroup$
    – LarsH
    Commented Mar 22, 2013 at 0:03
  • $\begingroup$ Actually, I've found that most GIS folks aren't aware of these complexities - they deal with too little of the earth at a time, or depend on the libraries to do it for them. I actually know it from real-world orbital trajectory calculations, so here or physics would be the right places. $\endgroup$ Commented Mar 22, 2013 at 1:42
  • $\begingroup$ I didn't mention this because I don't know your level of familiarity with sperical trig, but one way to see if the tangent point is on the arc is to compare the bearings from the pole to each end point and the tangent point. Though you may need to be careful regarding which quadrant your results are coming back in; i.e., 0 is between 330 and 30. $\endgroup$ Commented Mar 22, 2013 at 2:11
  • $\begingroup$ Regarding this last comment, which pole do you mean -- the point on the original y axis (90 degrees latitude), or the pole of the great circle through $Q$ and $R$? Regarding your initial answer, can you point me to how to form a 90-90-x triangle from the arc segment so as to find the poles? $\endgroup$
    – LarsH
    Commented Mar 22, 2013 at 3:03

$\newcommand{\Matrix}[1]{\left(\begin{matrix}#1\end{matrix}\right)}$ The perpendicular angular distance $α$ of point P from the great circle through points Q and R is $$ \sin(α) = \frac{\hat{P} ⋅ (\hat{Q} × \hat{R})}{|\hat{Q} × \hat{R}|} $$ where $⋅$ denotes the inner product, $×$ the vector cross product, $\hat{v}$ indicates an arbitrary vector with length 1, $|\vec{v}|$ stands for the length of an arbitrary vector $\vec{v}$, and $\hat{P}$, $\hat{Q}$, $\hat{R}$ stand for vectors of length 1 pointing from the center of the sphere to points P, Q, and R.

The inner product of two vectors is

$$ \Matrix{x_1 \\ y_1 \\ z_1} ⋅ \Matrix{x_2 \\ y_2 \\ z_2} = x_1x_2 + y_1y_2 + z_1z_2 $$

and the vector cross product is

$$ \Matrix{x_1 \\ y_1 \\ z_1} × \Matrix{x_2 \\ y_2 \\ z_2} = \Matrix{y_1z_2 − y_2z_1 \\ z_1x_2 − z_2x_1 \\ x_1y_2 − x_2y_1} $$

The polar coordinates $θ$ (longitude) and $φ$ (latitude) are converted to cartesian coordinates $x,y,z$ through

\begin{eqnarray} x & = & \cos(θ)\cos(φ) \\ y & = & \sin(θ)\cos(φ) \\ z & = & \sin(φ) \end{eqnarray}

The derivation of the first formula is as follows:

  1. The vector cross product $$\vec{S} = \hat{Q} × \hat{R}$$ is by definition perpendicular to both $\hat{Q}$ and $\hat{R}$, hence perpendicular to the plane of the great circle. Its length is not necessarily equal to 1, so we mark it as an ordinary vector $\vec{S}$, not a unit vector $\hat{S}$.

  2. Let $β$ be the angle between $\hat{P}$ and $\vec{S}$. Then, using the definition of the inner product, $$\hat{P}⋅\vec{S} = |\hat{P}| |\vec{S}| \cos(β) = |\vec{S}| \cos(β)$$ so $$\cos(β) = \frac{\hat{P}⋅\vec{S}}{|\vec{S}|}$$

  3. The angle $β$ between $\vec{S}$ and $\hat{P}$ and the angle $α$ between $\hat{P}$ and the plane of the great circle add up to 90°, which is the angle between $\vec{S}$ and the plane of the great circle, so $$\cos(β) = \sin(α)$$

  4. Combined, this yields the first equation.

The sign of $\sin(α)$ depends on the order of $\hat{Q}$ and $\hat{R}$ in the vector cross product. If you swap $\hat{Q}$ and $\hat{R}$, then $\sin(α)$ and $\vec{S}$ get multiplied by −1.

Let $z_S$ be the z coordinate of $\vec{S}$. Then P is north of the great circle through Q and R if $z_S\sin(α) \gt 0$, and south of the great circle if $z_S\sin(α) \lt 0$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .