public double DistanceFrom(GpsPoint other)
 {
     const int radius = 3956;                // Miles
     var lat1 = Lat * Math.PI / 180.0;
     var lat2 = other.Lat * Math.PI / 180.0;
     var diffLat = (other.Lat - Lat) * Math.PI / 180.0;
     var diffLon = (other.Lon - Lon) * Math.PI / 180.0;
     var a = Math.Pow(Math.Sin(diffLat / 2.0), 2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Pow(Math.Sin(diffLon / 2.0), 2);
     var c = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
     var d = radius * c;
     return d;
 }
Beispiel #2
0
        public double DistanceFrom(GpsPoint other)
        {
            const int radius  = 3956;               // Miles
            var       lat1    = Lat * Math.PI / 180.0;
            var       lat2    = other.Lat * Math.PI / 180.0;
            var       diffLat = (other.Lat - Lat) * Math.PI / 180.0;
            var       diffLon = (other.Lon - Lon) * Math.PI / 180.0;
            var       a       = Math.Pow(Math.Sin(diffLat / 2.0), 2) + Math.Cos(lat1) * Math.Cos(lat2) * Math.Pow(Math.Sin(diffLon / 2.0), 2);
            var       c       = 2 * Math.Atan2(Math.Sqrt(a), Math.Sqrt(1 - a));
            var       d       = radius * c;

            return(d);
        }