1

I have two geo coordinates positions on the earth.

Using .NET I can easily calculate the distance:

GeoCoordinate a = new GeoCoordinate(50, 8);
GeoCoordinate b = new GeoCoordinate(34, -118);
double distanceInMeters = a.GetDistanceTo(b);

This uses the Haversine formula and execution is extremely fast.

How can i get the bearing using the same spherial model which the Haversine formula uses?

I would be happy with something like:

double bearing = HaversineBearingCalculator.calcBearingInDegrees(a, b);

or even

double bearing = a.GetBearingTo(b);

However .NET does not seem to offer anything like it.

Hossein Narimani Rad
  • 31,361
  • 18
  • 86
  • 116
user2088476
  • 603
  • 6
  • 15
  • Can't you define your own method that does exactly that? Like here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/8b035fff-7e0e-4ba2-acf4-8e4e022fbe7b/how-to-calculate-bearing-in-c?forum=csharpgeneral – Alexandru Pupsa May 12 '17 at 15:33
  • sorry, but your example works in a flat surface, I am talking about planet earth as a sphere here... – user2088476 May 12 '17 at 15:36
  • What do yout want? Orthodrome, loxodrome? – Deblaton Jean-Philippe May 12 '17 at 15:39
  • 1
    There is no absolute bearing over a sphere; your path would be of the "Great Circle" and the only 2 absolute values is the initial and terminal bearings. All other bearings would need to be calculated by the current location on the path and the destination. – Mad Myche May 12 '17 at 15:40
  • 2
    @user2088476 Sorry, maybe this then http://stackoverflow.com/questions/2042599/direction-between-2-latitude-longitude-points-in-c-sharp – Alexandru Pupsa May 12 '17 at 15:44
  • I don't get why this question is upvoted. Issue is not related to coding, but to navigation understanding. And the question is impossible to solve – Deblaton Jean-Philippe May 12 '17 at 15:44
  • The last one gives 270 for your example. Is that correct? – Alexandru Pupsa May 12 '17 at 15:44
  • One solution is to project your lat/long pairs to a equal-angle projection system. Then use simple planar calculation to find the bearing between x/y pairs – Hossein Narimani Rad May 12 '17 at 15:55

0 Answers0