Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm new here so sorry if this is a really silly question but I can't solve it myself.

If I have two points on a unit sphere, A and B, and the shortest path from A to B over the surface of the sphere, then how do I calculate the direction of this line at point B (as a vector)?

Do I need to compute this using quaternions? I have read a bit about it but find it very hard to understand how to use them. Alternatively, if rotation matrices can be used I would be very happy too.

share|cite|improve this question
It seems to me that your problem is discussed in this thread. – Jyrki Lahtonen May 31 '12 at 15:35
@Jyrki Thanks for the link. Looks like it does, and it gives a good deal of background too. I just find the answer here easier to follow though, but that is a matter of taste I guess. – Paul May 31 '12 at 15:50
the answers there are "essentially" the same as the answer given by Peter H. here. He manages to do it with less words though :-). OTOH he doesn't need to discuss the conversions from one coordinate system to another. – Jyrki Lahtonen May 31 '12 at 15:55
up vote 2 down vote accepted

The shortest paths connecting two points on a sphere are arcs of great circles, so the direction you are looking for is the tangent to the great circle containing $A$ and $B$. This tangent

  • lies in the plane of the great circle, i.e. is orthogonal to the plane normal given by $A \times B$
  • is orthogonal to the location vector of $B$

Therefore the direction that points from $B$ towards $A$ is the cross product of these two vectors, given by $B \times (A \times B)$.

share|cite|improve this answer
Wow, looking at it that way it is brilliantly simple and very understandable. Thanks. – Paul May 31 '12 at 15:46
On a side note, how does the magnitude of this vector relate to the derivative? – Paul May 31 '12 at 16:11

This works provided the points are not antipodes. Write an equation for the line connecting the two points; that is of the form $r(t) = (a + bt){\rm\bf i} + (c + dt){\rm\bf j} + (e + ft){\rm\bf k}. $ Now divide out by the norm of this function and you have it.

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.