CSharp examples for System:Math Geometry
Distance for latitude and longitude
using System;/*from ww w. ja va2s .co m*/ public class Main{ public static double Distance(double latitude1, double longitude1, double latitude2, double longitude2) { var theta = longitude1 - longitude2; var distance = Math.Sin(DegreesToRadians(latitude1)) * Math.Sin(DegreesToRadians(latitude2)) + Math.Cos(DegreesToRadians(latitude1)) * Math.Cos(DegreesToRadians(latitude2)) * Math.Cos(DegreesToRadians(theta)); distance = Math.Acos(distance); distance = RadiansToDegrees(distance); return distance * 60 * 1.853159616; } private static double DegreesToRadians(double degrees) { return degrees * Math.PI / 180.0; } }