public static float CartesianDistance(GPSLocation cord1, GPSLocation cord2) { var pos1 = GPSToCartesian(cord1); var pos2 = GPSToCartesian(cord2); var distance = Mathf.Sqrt( Mathf.Pow(pos1.x - pos2.x, 2.0f) + Mathf.Pow(pos1.y - pos2.y, 2.0f) + Mathf.Pow(pos1.z - pos2.z, 2.0f)); return(distance); }
public static float CoordinateDistance(GPSLocation cord1, GPSLocation cord2) { var latDistance = cord1.Latitude - cord2.Latitude; var longDistance = cord1.Longitude - cord2.Longitude; longDistance = longDistance > 180.0f ? longDistance - 360 : longDistance; longDistance = longDistance < -180.0f ? longDistance + 360 : longDistance; var result = Mathf.Sqrt ( Mathf.Pow(latDistance, 2.0f) + Mathf.Pow(longDistance, 2.0f) ); return(result); }