# Coordinates of interception point Y with XY being the shortest distance of X to AB on sphere

How would one calculate the interception point $Y$ with $\overleftrightarrow{XY}$ being the shortest distance of $X$ to $\overleftrightarrow{AB}$?

This answer to the question How to find the distance between a point and line joining two points on a sphere? describes how to calculate the distance, but not the coordinates.

What would be the most direct way to calculate the coordinates of interception point $Y$?

I since found out that this problem is also called the along track distance and have implemented it but have troubles checking my results.

For completeness here are the formulas and their code counterpart I have used and implemented:

$dxt = asin(\sin(d_{13}/R) * \sin( \phi_{13}−\phi_{12})) * r$

with

• $d_{13}$ is distance from start point to third point
• $\phi_{13}$ is (initial) bearing in degrees from start point to third point
• $\phi_{12}$ is (initial) bearing in degrees from start point to end point
• $r$ is the earth’s radius

in JavaScript:

var dXt = Math.asin(Math.sin(d13/R)*Math.sin(Math.PI / 180 * (brng13-brng12))) * R;


in Java:

final double dt = Math.asin(Math.sin(d13 / r) * Math.sin(Math.toRadians(b13 - b12))) * R;


then I calculate the Along Track Distance (following the formula on the site)

$dat = acos(\cos( d_{13}/r) / \cos(dxt/r)) * r$

where

• $d13$ is distance from start point to third point
• $dxt$ is cross-track distance
• $r$ is the earth’s radius

in JavaScript:

var dAt = Math.acos(Math.cos(d13/R)/Math.cos(dXt/R)) * R;


in Java:

final double dAt = Math.acos( Math.cos(d13 / r) / Math.cos(dXt / r) ) * r;


As a test case I have

• $A (0,0)$
• $B (90,0)$
• $X (45,45)$

and get the following results my with my implementation

• $3335847.799336763$ for $\overleftrightarrow{XY}$
• $6086322.17407125$ for $\overleftrightarrow{AB}$

and thus $(54.735, 0) as coordinates for Y Using$r * \cos (lat)$the radius on the given latitude is$4504977.303$, thus$1/8$of the circumference is$3538200.9$. Shouldn't$Y$be$(0, 45)$? Surely the shortest distance from$X (45, 45)$to$\overleftrightarrow{AB}$is the great circle on 45° latitude ? Thus the cross track -distance should be$3538200.9$. Am I lacking imagination in three-dimensions? - Maybe start by rotating the sphere so that A is at the north pole and B is on the$xz\$-plane? (Just a thought.) –  Jesse Madnick Jun 22 '12 at 6:10