Hi Francesco,
In addition to the reply of David, if you have to do it with only latitude / longitude you can use this formula:
Code:
public static int CalcDistance(double lat1, double lon1, double lat2, double lon2, out int heading)
{
double lat = lat2 - lat1;
double lon = (lon2 - lon1) * Math.Cos(Tools.deg2rad((int)((lat1 + lat2) / 2)));
double dist = Math.Sqrt(lat * lat + lon * lon);
heading = Tools.rad2deg(Math.Acos(lat / dist));
if (lon < 0) // Western direction
heading = 360 - heading;
return (int)(dist * 60 * 1852);
}
private static double deg2rad(int degree)
{
return degree * Math.PI / 180;
}
private static int rad2deg(double rad)
{
return (int)(rad * 180 / Math.PI);
}