Perpendicular Distance from Point to Arc

I am sure the major portion of this has been covered, but I have an exception that I need to hash out.

I want to find the intersection of two great circle arcs (numerically). I have already determined the location of the two intersection points of the two corresponding great circles. However, this leave me with the problem of determining which point lies on the great circle arc.

Letlet $\displaystyle p_1,\,q_1, p_2, q_2$ define the great circle arcs, $\displaystyle A_1,A_2$, respectively, and let $\displaystyle I_1,\, I_2$ correspond to the intersections of the great circles. These intersections are antipodal of eachother, which is what causes my problem. To calculate the shortest distance between a point, $\displaystyle X$ and a great circle I use the following

$\displaystyle n = p \times q $

then the perpendicular distance is given by

$\displaystyle \theta = \cos^{-1}(n \cdot X) - \frac{\pi}{2}$.

From here I check to see if $\displaystyle \theta \le \epsilon$.

But, because of $\displaystyle 0 \le \cos^{-1} X \le \pi$ I get that both $\displaystyle I_1,\, I_2$ are on the arc. How do I get the proper angle from $\displaystyle \cos^{-1}$ using the information given?

Re: Perpendicular Distance from Point to Arc

Is this a poorly asked question? It seems strange that no one has been able to answer this.

Re: Perpendicular Distance from Point to Arc

It is a little difficult to follow. I assume that one great circle arc is defined by two vectors p1 and q1, and the other by p2 and q2, correct? So you are trying to find the angular separation between X and either one of the great circles. I don't understand what you mean by "I get that both I_1 and I_2 are on the arc" -- they are the intersection points of the two great circle arcs, so yes, they are both "on the arc."

I also don't get the formula for angular separation: $\displaystyle \theta = \cos^{-1}(n \cdot X) - \frac {\pi}{2}$: it seems with this formula that if X is on the arc then X is perpendicular to n, the dot product of n and X is 0, and hence the formula yields $\displaystyle \theta = \frac{-\pi}2$ instead of 0 as expected. I would think $\displaystyle \theta = \sin^{-1}(n \cdot X)}$ would work better? One other thing - the values for theta ought to lie between 0 and pi/2, if the dot product yields a negative number I think you want to use its absolute value: $\displaystyle \theta = \sin^{-1}(|n \cdot X|)}$

Re: Perpendicular Distance from Point to Arc

I define two Arcs $\displaystyle A_1,\, A_2$ by the points $\displaystyle \left\{p_1,\,q_1\right\},\left\{p_2,\,q_2\right\}, $ respectively, just as you said. What I want is $\displaystyle A_1 \cap A_2$. However, the way I have done this is by finding the intersection of the of two great circles corresponding to the given points. Since I find the intersection of two great circles, I get two intersections $\displaystyle I_1,\, I_2$. Only one of these two points actually lies on $\displaystyle A_1 \cap A_2$, so I figured I could just find the distance of each point to one of the arcs; the point with an angular distance closest to 0 would be the intersection of the two arcs. However, I get the same angular distance for both points. I hope this description is clearer.

EDIT: The problem is that both $\displaystyle I_1$ and $\displaystyle I_2$ lie on the great circle, however only one lies on the arc. The question is how do I determine which lies on the arc?

Re: Perpendicular Distance from Point to Arc

Quote:

Originally Posted by

**lvleph** The problem is that both $\displaystyle I_1$ and $\displaystyle I_2$ lie on the great circle, however only one lies on the arc. The question is how do I determine which lies on the arc?

OK, I see. Two great circles will intersect at two points (assuming they are not coplanar), whereas two circle segments may have 0, 1 or 2 intersection points. How about this - if the angular distance from p to I_1 plus the angular distance from I_1 to q equals the angular distance from p to q then I_1 is between p and q and hence on the arc. If I_1 is not on the arc then the sum of these angles would be greater than the arc. You would have to use positive angles only, and control for the case where the arc is greater than 180 degrees.

Re: Perpendicular Distance from Point to Arc

That sounds plausible. The other solution I was thinking might works is to look at $\displaystyle \|p_1 - I_1\|_0$ and $\displaystyle \|p_1 - I_2\|_0$ the smaller distance is the point I want. This will work because I know my arcs are small.

Re: Perpendicular Distance from Point to Arc

If the arcs are always less than 90 degrees in length and if there is always an intersect point on the arcs then yes, it would work.

Re: Perpendicular Distance from Point to Arc

Good point, part of what I am checking is if there is even an intersection, so my method won't work.

Re: Perpendicular Distance from Point to Arc

Numerically, your test has a problem. If the intersection is one of the end points of an arc it can cause acos to throw NaN. But, I can detect this.