# Distance between a point on a sphere and a great circle arc

1. Mar 23, 2011

### Fredster

Hi all,

Let me state up front that I'm a math idiot. I minored in it in college 20+ years ago and haven't needed it as a software engineer...until now.

I'm trying to solve a problem for work that's got me pulling my hair out, mostly because I'm having to relearn so much math I'd forgotten. What I'm currently struggling with is this:

Given two points (A and B) on the Earth, which I can assume is spherical because my calculations don't have to be super-accurate, imagine the minor great circle arc connecting them. If I have a third point C, I'd like to know the distance between AB and C. I know how to find the distance between C and the great circle itself, but that's not exactly what I need unless C happens to be perpendicular to the great circle somewhere along AB. Chances are very good that C will most often actually be closest to A or B.

I've been doing all my other work with these points as unit vectors instead of lat/lon, and if there's a solution to my problem that's easily done with vectors, I'd like to do it that way. I've implemented the algorithm here:

http://mathforum.org/library/drmath/view/51785.html

and what I'm really hoping is that I can just put a couple of checks at the beginning to see if C happens to be closest to A or B before doing those calculations. In a linear system, I can use the dot product to determine where C lies relative to AB, and I suspect (or at least hope!) that something similar can be done in a spherical system. I just don't know what to do.

Thanks in advance for anyone who can help out, and please use small words because l'm easily confused. :)

2. Mar 23, 2011

### Fredster

To make a stab at answering my own question, if I calculate the angle O between BC and BA and it's greater than 90 degrees, B is the closest point to C; the same would apply to the angle between AC and AB.

Am I at least in the vicinity of a workable solution?

3. Aug 7, 2011

### axelgron

Hi Fredster,

I'm not a math expert either. But in my Master's thesis I made some calculations that seem similar to your request. You can find it here:
http://www.ai.rug.nl/~axel/publ.html
It is the link at the bottom of the page ("Speeding up the computation...").
Please let me know if this is of any help to you.

Regards,
Axel Brink.