[Math] How to calculate the angle between two lines on a sphere

calculusgeometrytrigonometry

Suppose I have three points on a sphere which form a triangle.

I'm interested in finding i) the angle between two line segments, and ii) the distance between two points as a function of the length of the line segments given the angle.

This is directly analogous to trigonometry, except now my geometry is not euclidian.

How does trigonometry change on a sphere?

EDIT: It should be noted that the location data I have is a lat,lon coordinate pair.

Best Answer

We measure latitude positive or negative, from the Equator. But I’ll have to talk about the “colatitude”, the distance from the North Pole, so this is $90^\circ-$ ordinary latitude.

Look at your two points, given by colatitude and longitude. Draw geodesics (arcs of great circle) from them to the North Pole, and the geodesic between them. You see that you have an SAS situation (“side-angle-side”), the sides are the lines $\alpha$ and $\beta$ going to the NP, and the angle $\Gamma$ is the difference in the two longitudes. For this, you use the Direct Law of Cosines (there’s a “Polar Law” as well), it goes as follows: $$ \cos\gamma=\cos\alpha\cos\beta+\sin\alpha\sin\beta\cos\Gamma\,, $$ where the lower-case Greek letters are the (angular) measures of sides and the upper-case letters are the angles at the opposite vertices, as is a common convention. That gives your distance $\gamma$ between your two cities, in angular measure of course.

Now, for the angle between two geodesics, you can use the Law of Sines, very easily stated as $$ \frac{\sin\alpha}{\sin A}=\frac{\sin\beta}{\sin B}=\frac{\sin\gamma}{\sin\Gamma}\,. $$ You have the angle $\Gamma$ and now (thanks to your previous computation) the side $\gamma$, so you can very quickly get the angles $A$ and $B$. These can be interpreted as telling you the “initial headings” of a ship sailing from your first city to the second, and vice versa, since they’re angles from due North. When you have the other sides of the triangle, you can add or subtract suitably. You need to draw yourself a picture, of course.

You can also find the angles of your triangle from the three separate distances among the three cities and then use the DLC, solving for the one angle in the formula, but I think LS is easier.

Related Question