-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathm_xydist.m
32 lines (23 loc) · 884 Bytes
/
m_xydist.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function dist = m_xydist(x,y)
% M_XYDIST Spherical earth distance between points in map projection coordinates.
% RANGE=M_XYDIST(X,Y) gives the distance in kilometers between
% successive points in the vectors X and Y which are coordinates
% in the current map projection. This function is useful for finding
% distances between points "picked off" a map, e.g.:
%
% Example:
% G = GINPUT(2); km_dist = M_XYDIST(G(:,1),G(:,2));
%
% See also M_LLDIST
% Rich Pawlowicz (rich@ocgy.ubc.ca) 6/Nov/00, based largely on an
% idea by Deirdre Byrne.
% This software is provided "as is" without warranty of any kind. But
% it's mine, so you can't sell it.
global MAP_PROJECTION MAP_VAR_LIST
if isempty(MAP_PROJECTION),
disp('No Map Projection initialized - call M_PROJ first!');
return;
end;
% get lon, lat coords
[lon,lat] = m_xy2ll(x,y);
dist = m_lldist(lon,lat);