using System.Collections.Generic;
public static void Main()
Console.WriteLine("Hello World");
var data = new GeoPoint[]{
new GeoPoint(47.1716523, 8.5317303),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1716980, 8.5317653),
new GeoPoint(47.1717705, 8.5318116)
List<double> bearings = Enumerable.Range(1, data.Length - 1).Select(i => CalculateBearing(data[i - 1], data[i])).ToList();
foreach(var az in bearings)
public GeoPoint(double lat, double @long)
public double Lat { get; }
public double Long { get; }
public static double CalculateBearing(GeoPoint p1, GeoPoint p2)
const int degrees180 = 180;
const int degrees360 = 360;
double ToRad(double value) => value * (Math.PI / degrees180);
double ToDegrees(double angle) => angle * degrees180 / Math.PI;
double a = ToRad(p1.Lat);
double b = ToRad(p1.Long);
double c = ToRad(p2.Lat);
double d = ToRad(p2.Long);
if (Math.Abs(Math.Cos(c) * Math.Sin(d - b)) < double.Epsilon)
res = c > a ? 0 : degrees180;
double angle = Math.Atan2(Math.Cos(c) * Math.Sin(d - b), Math.Sin(c) * Math.Cos(a) - Math.Sin(a) * Math.Cos(c) * Math.Cos(d - b));
res = (ToDegrees(angle) + degrees360) % degrees360;