GREAT CIRCLE SAILING
====================

Distance

The great circle distance in degrees between Point1 (lat1, lon1) and Point2 (lat2, lon2) is easily calculated:

cos(D)= Sin(lat1) * Sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1)

or what is the same:

D= arccos(Sin(lat1) * Sin(lat2) + cos(lat1) * cos(lat2) * cos(lon2 - lon1))

In this paper we assume the following signs N=+, S=-, W=+, E=- .

cos(D) will always fall in the range -1 < cos(D) < 1 and (D) will be a positive angle: 0° < D < 180°. You can use a formula that will use the arctan function but this will give a result in the -90° to +90° range and you need to add 180° if the result is negative.

• multiply D by 60 to obtain distance in nautical miles or
• multiply D by 69 to obtain distance in statute miles or
• multiply D by 111.12 to obtain distance in Km

Azimuth

The azimuth or initial course from point 1 (origin) to point 2 (destination) Zn can also be easily calculated. Zn is always measured from North to East from 0° to 360°. First we calculate Z. If we have considered West longitudes as positive we use this formula:

```                           Sin(lon2-lon1)
Tan(Z) =  --------------------------------------------------
sin(lat1) * cos(lon2-lon1) - cos(lat1) * tan(lat2)
```

(If we had considered East longitudes as being positive we would need to change the sign on one side of this equation.)

The function ATAN( ) returns a value between -90° and +90° so Z needs to be adjusted to the right quadrant in order to obtain Zn: 0° < Zn < 360°

```    If sign(sin(Z)) = sign(sin(lon2-lon1))
Then Zn = Z + 180
Else, If Z < 0
Then Zn = Z + 360
Else Zn = Z
```

Expressed in another way:
 Zn 0° < lon2 - lon1 lon2 - lon1 < 0° Z > 0 Z + 180 Z Z < 0 Z + 360 Z + 180

The following formula adds 180° if needed to reduce Zn to the correct quadrant:

Zn = Z + 90 * (1 + sign( sin(lon2-lon1) * sin(Z) ) )