Name

CL_gm_sphericDist — Great circle distance between 2 geographic coordinates

Calling Sequence

   dist = CL_gm_sphericDist(p1,p2[,er])
   
   

Description

  • Given two points in geocentric coordinates (longitude and latitude), this functions gives the great circle distance between them approximating the planet as a sphere. The three following formulas give the exact great circle distance between two points (lambda: longitude, phi:latitude) for a sphere of radius 1. However, the first formula (1) is used on this funtion due to possible rounding errors of formulas (2) and (3) for small distances or antipodal points.
  • Last update : 14/2/2008

Parameters

p1:

first point [LON;LAT] geocentric coordinates of first point [rad] (2xN)

p2:

second point [LON;LAT] geocentric coordinates of second point [rad] (2xN)

er :

(optional) earth radius [m] (default %CL_eqRad)

dist:

great circle distance between p1 and p2 [m] (1xN)

Authors

CNES - DCT/SB

Bibliography

1 R.W. Sinnott, "Virtues of the Haversine", Sky and Telescope, vol. 68, no. 2, 1984, p. 159

2 Weisstein, Eric W. "Great Circle." From MathWorld. http://mathworld.wolfram.com/GreatCircle.html

See also

CL_co_car2sph, CL_co_sph2car

Examples

// Spherical distance between Toulouse (43° 36' 19"N, 1° 26' 34"E) and Barcelona (41° 24' 7"N, 2° 10' 17"E)
tlse_lat = 43 + 36/60 + 19/3600;
tlse_lon = 1 + 26/60 + 34/3600;
bcn_lat = 41 + 24/60 + 7/3600;
bcn_lon = 2 + 10/60 + 17/3600;
tlse_coord = CL_deg2rad([tlse_lon;tlse_lat]);
bcn_coord = CL_deg2rad([bcn_lon;bcn_lat]);
tlse_bcn = CL_gm_sphericDist(tlse_coord,bcn_coord); //great circle distance toulouse - barcelona
disp('Toulouse - Barcelona: '+string(tlse_bcn / 1000)+' km');