• Let 'R' be the radius of Earth
• 'L' be the longitude
• 'θ' be latitude
• 'β' be Bearing
Denote point A and B as two different points, where 'La' is point A longitude and 'θa' is point A latitude, similarly assume for point B. Bearing would be measured from North direction i.e 0° bearing means North, 90° bearing is East, 180° bearing is measured to be South, and 270° to be West.
Note: If bearing is denoted with +ve or -ve initials whose values lies between 0° to 180°, then -ve is denoted for South and West sides.
Bearing from point A to B, can be calculated as,
β = atan2(X,Y),
where, X and Y are two quantities and can be calculated as:
X = cos θb * sin ∆L
Y = cos θa sin θb - sin θa cos θb * cos ∆L
Example:
Lets us take an example to calculate bearing between the two different points with the formula:
Kansas City: 39.099912, -94.581213
St Louis: 38.627089, -90.200203
So X and Y can be calculated as,
X = cos(38.627089) * sin(4.38101)
X = 0.05967668696
And
Y = cos(39.099912) sin(38.627089) - sin(39.099912) cos(38.627089) * cos(4.38101)
Y = 0.77604737571 0.62424902378 - 0.6306746155 0.78122541965 * 0.99707812506
Y = -0.00681261948
So as, β = atan2(X,Y) = atan2(0.05967668696, -0.00681261948)
β = 96.51°
This means, from Kansas City if we move in 96.51° bearing direction, we will reach St Louis.