Q: How to convert Earth coordinates to distances ?
Here are the functions I use. They are included into CODAS package (by E.Firing,et al.), but I am unsure who the author is.
function dy = lat_to_m(dlat,alat)
% dy = lat_to_m(dlat,alat)
% dy = latitude difference in meters
% dlat = latitude difference in degrees
% alat = average latitude between the two fixes
% Reference: American Practical Navigator, Vol II, 1975 Edition, p 5
rlat = alat * pi/180;
m = 111132.09 * ones(size(rlat)) - ...
566.05 * cos(2 * rlat) + 1.2 * cos(4 * rlat);
dy = dlat .* m ;
function dx = lon_to_m(dlon, alat)
% dx = lon_to_m(dlon, alat)
% dx = longitude difference in meters
% dlon = longitude difference in degrees
% alat = average latitude between the two fixes
rlat = alat * pi/180;
p = 111415.13 * cos(rlat) - 94.55 * cos(3 * rlat);
dx = dlon .* p;
function dlat = m_to_lat(dy, alat)
%
% dy = latitude difference in meters
% dlat = latidute difference in degrees
% alat = average latitude between the two fixes
% Reference: American Practical Navigator, Vol II, 1975 Edition, p 5
rlat = alat * pi/180;
m = 111132.09 * ones(size(rlat)) - ...
566.05 * cos(2 * rlat) + 1.2 * cos(4 * rlat);
dlat = dy ./ m;
function dlon = m_to_lon(dx, alat)
%
% dlon = longitude difference in degrees
% dx = longitude difference in meters
% alat = average latitude between the two fixes
rlat = alat * pi/180;
p = 111415.13 * cos(rlat) - 94.55 * cos(3 * rlat);
dlon = dx ./ p;