Don’t you think it would be really great to be able to work out the precise bearing of a place in relation to where you are now? The calculation for this is rather simple if you have the geographical coordinates of the two points that you would like to find the bearing of.
The code below calculates the angle between the two coordinates. The last function call to ConvertToBearing puts the value into the right range. The atan function returns a value back (converted to degrees), which is in the range of -180 to 180 degrees, whereas, bearing is normally given in the range 0 - 360 degrees.
Originally posted on my old blog, Smoky Cogs, on 8 Oct 2009