CSharp examples for System:Math Geometry
Get Distance
using System.Text; using System.Linq; using System.Collections.Generic; using System;//from ww w . jav a 2 s.c o m public class Main{ public static double GetDistance(double startLat, double startLng, double endLat, double endLng) { double radLat1 = rad(startLat); double radLat2 = rad(endLat); double a = radLat1 - radLat2; double b = rad(startLng) - rad(endLng); double s = 2 * Math.Asin(Math.Sqrt(Math.Pow(Math.Sin(a / 2), 2) + Math.Cos(radLat1) * Math.Cos(radLat2) * Math.Pow(Math.Sin(b / 2), 2))); s = s * EARTH_RADIUS; s = Math.Round(s * 10000) / 10000; return s; } }