Exemple #1
0
        public static double CalculateBearing(GeoCoord startPoint, GeoCoord endPoint)
        {
            double lat1     = DegToRad(startPoint.Lat);
            double lat2     = DegToRad(endPoint.Lat);
            double deltaLon = DegToRad(endPoint.Lon - startPoint.Lon);

            double y       = Math.Sin(deltaLon) * Math.Cos(lat2);
            double x       = Math.Cos(lat1) * Math.Sin(lat2) - Math.Sin(lat1) * Math.Cos(lat2) * Math.Cos(deltaLon);
            double bearing = Math.Atan2(y, x);

            // since atan2 returns a value between -180 and +180, we need to convert it to 0 - 360 degrees
            return((RadToDeg(bearing) + 360) % 360);
        }
Exemple #2
0
 public static GeoCoord Interpolate(GeoCoord p0, GeoCoord p1, double t)
 {
     return(new GeoCoord(Lerp(p0.Lon, p1.Lon, t), Lerp(p0.Lat, p1.Lat, t)));
 }
Exemple #3
0
 public static double MetersDistanceTo(GeoCoord p0, GeoCoord p1)
 => MetersDistanceTo(p0.Lon, p0.Lat, p1.Lon, p1.Lat);