Exemplo n.º 1
0
        //gets the angle between two coordinates
        public static double GetDirection(GeoCoordinate coordinates1, GeoCoordinate coordinates2)
        {
            var latitude1 = DegreeToRadian(coordinates1.Latitude);

            var latitude2 = DegreeToRadian(coordinates2.Latitude);

            var longitudeDifference = MathHelpers.DegreeToRadian(coordinates2.Longitude - coordinates1.Longitude);



            var y = Math.Sin(longitudeDifference) * Math.Cos(latitude2);

            var x = Math.Cos(latitude1) * Math.Sin(latitude2) -

                    Math.Sin(latitude1) * Math.Cos(latitude2) * Math.Cos(longitudeDifference);



            return((RadianToDegree(Math.Atan2(y, x)) + 360) % 360);
        }