Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

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

θ = atan2( sin(Δlong).cos(lat2), cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong) )

Does it take into account that we may be dealing with a trapezoid rather than a rectangle

share|cite|improve this question
That's one very good answer. Any other answer that do not uses matrix? – Jim Thio Jan 27 '12 at 7:57
up vote 1 down vote accepted

The title and the body contain two different questions; this is an answer to the question in the title.

First rotate around the polar axis to put the first point on the prime meridian; this doesn't change the required bearing. Denoting latitude by $\theta$ and longitude by $\phi$, the coordinates of the points are now $(\theta_1,0)$ and $(\theta_2,\Delta\phi)$, respectively. Now rotate by $\theta_1$ around an equatorial axis at $\phi=\pm\pi/2$ to take the first point to the south pole. Now the required bearing is the longitude to which the second point has been rotated.

In Cartesian coordinates, the matrix of the rotation that takes the first point to the south pole is


Applying this to the second point yields


Then you get the bearing by calculating the longitude of that point as $\operatorname{atan2}(y,x)$.

As regards the question in the body, the derivation uses neither rectangles nor trapezoids. You may be referring to the fact that a rectangle in latitude-longitude space has roughly the shape of a trapezoid in Euclidean space. However, it's not exactly a trapezoid, and the derivation uses neither the approximation of a trapezoid, nor the even less accurate approximation of a rectangle, but calculates the bearing exactly as the local inclination of the great circle through the two points.

share|cite|improve this answer
before I do pencil pushing to verify, knows other answer that's easier to derive? – Jim Thio Jan 27 '12 at 7:57
@Jim: I don't think there's a substantially simpler form for the answer. There might be an easier way to derive this one, but I can't think of one. – joriki Jan 27 '12 at 10:06
+1 pencil pushing commence !!!! – Jim Thio Jan 29 '12 at 9:51

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.