Given line AB made from two Latitude/Longitude co-ordinates, and point C, how can I calculate the position of D, which is C projected onto D.


AB line with C projected as D


1 Answer 1


What to do

Express $A,B,C$ using Cartesian Coordinates in $\mathbb R^3$. Then compute

$$D=\bigl((A\times B)\times C\bigr)\times(A\times B)$$

Divide that vector by its length to project it onto the sphere (with the center of the sphere as center of projection). Check whether you have the correct signs; the computation might instead result in the point on the opposite side of the earth, in which case you'd simply flip all coordinate signs. The correct point is likely the one closer to e.g. the point $A+B$, so you can simply try both alternatives and choose the correct one.

Then turn the resulting Cartesian vector back into latitude and logitude.

How this works

The description above was obtained by viewing the sphere as the real projective plane. In that view, a point of the real projective plane corresponds to two antipodal points on the sphere, which is the source of the sign ambiguitiy I mentioned.

$P=A\times B$ is a vector orthogonal to both $A$ and $B$. Every great circle which is orthogonal to $AB$ will pass through the projection of $P$ onto the sphere. $Q=P\times C$ is orthogonal to both $P$ and $C$, so it is orthogonal to the great circle which connects $C$ with $P$ (resp. its projection onto the sphere). That great circle is the one which also connects $C$ and your desired $D$. $D=Q\times P$ is orthogonal to both $P$ and $Q$, so it lies both on the greatcircle $AB$ and the greatcircle $CD$. Therefore it must point in the direction of the desired point. Project onto the sphere, choose the correct point from the antipodal pair, and you have the solution.


You must log in to answer this question.

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