# Equation for calculating azimuth between two points

Does anybody know an equation or approximation for calculating the azimuth as a function of latitudes and longitudes of both the points.

For example I have Princeton, NJ is at 40.3571° N, 74.6702° W, and Boston is at 42.3581° N, 71.0636° W, how do I calculate the azimuth between these two places?

Thanks.

• I’m fairly savvy in spherical geometry, but I don’t know what you mean by “azimuth”, since the usual definition of the term does not seem to apply here. Do you mean the heading, say if you want to go from P to B, which direction, expressed as degrees clockwise from North, you want to go in? You should be aware that this number will change as you progress; in particular the heading form B to P is not equal to $180^\circ+$ the heading from P to B. – Lubin Mar 19 '14 at 20:15
• I didn't know that, and yes by Azimuth I meant the heading, the degrees clockwise from North. How do you calculate heading? I assume its a function of distance already traveled. – user3014093 Mar 19 '14 at 23:52

I’m sure that there are quicker and dirtier ways of getting a very accurate but approximate answer, especially for a relatively short flight like the one you specify. but if we were going, say, from Princeton to Paris in a great circle route, then the heading would certainly vary greatly as we flew.

The problem is simple spherical trigonometry. You have a triangle with vertex at the North Pole, I’ll label this $C$, and the two towns, Princeton labeled $A$ and Boston labeled $B$. Then the side of the triangle opposite Boston we label $b$, in arc-length, that’s the complement of the latitude of Princeton, namely $49.6429^\circ$, and the other leg is labeled $a$, it’s the complement of the latitude of Boston, namely $47.6419^\circ$, if I‘ve done my mental subtractions right. Now the angle at the vertex is $C=3.6066^\circ$, the difference of the two longitudes.

Notice that you have a SAS situation, side-angle-side, and just as in plane trigonometry, you use the Law of Cosines to get the length of the side opposite $C$, and then the Law of Sines to get the two angles at $A$ and $B$. the Law of Cosines says: $$\cos c=\cos a\cos b+\sin a\sin b\cos C\,,$$ and yes, if you recall the corresponding formula in plane trigonometry, that is a plus sign rather than a minus sign. Anyway, you now have the length of $c$, and you use the Law of Sines to get the angles at $A$ and $B$: $$\frac{\sin A}{\sin a}=\frac{\sin B}{\sin b}=\frac{\sin C}{\sin c}\,.$$ I hope that you’ve been following this description with a diagram that you’ve drawn. If so, you see that the heading from Princeton to Boston is just $\angle A$, and the heading from Boston to Princeton is $180^\circ-\angle B$. Remember that the sum of the three angles of a spherical triangle is always greater than $180^\circ$. That’s why you can’t just subtract $A+C$ from $180^\circ$ to get $B$, though for a thin triangle like this the two numbers are not at all far apart. If you’re doing a serious navigation problem and want to know your heading at all times, the way to get your answer is going to depend on what your givens are. All can be solved using Sines and Cosines, though the Law of Cosines has a variant (“polar”) formulation for the ASA situation, namely $$\cos C=-\cos A\cos B+\sin A\sin B\cos c\,.$$

The problem for a sphere is addressed in the Wikipedia article, Great-circle navigation.

The more interesting problem is for an ellipsoid of revolution. This is addressed in the Wikipedia article, Geodesics on an ellipsoid.

If you just want to get the answer use this online calculator (this gives the azimuth as 52.45173514°).

If you want the path plotted on Google Maps, use this link.