source: trunk/SRC/Interpolation/ll_narcs_distances.pro @ 101

Last change on this file since 101 was 101, checked in by pinsard, 18 years ago

start to modify headers of Interpolation *.pro files for better idldoc output

  • Property svn:executable set to *
File size: 3.5 KB
Line 
1;+
2;
3; @file_comments
4; This function returns the longitude and latitude [lon, lat] of
5;a point a given arc distance (-pi <= Arc_Dist <= pi), and azimuth (Az),
6;from a specified location Lon0, lat0.
7;       Same as LL_ARC_DISTANCE but for n points without do loop.
8;
9; @categories Mapping, geography
10;
11; @examples
12;Result = LL_NARCS_DISTANCES(Lon, lat0, Arc_Dist, Az)
13;
14;    @param Lon0 {in}{required}  An array containing the longitude of the starting point.
15;             Values are assumed to be in radians unless the keyword
16;             DEGREES is set.
17;    @param Lat0 {in}{required}  An array containing the latitude of the starting point.
18;             Values are assumed to be in radians unless the keyword
19;             DEGREES is set.
20;    @param Arc_Dist {in}{required}  The arc distance from Lon_lat0. The value must be between
21; -!PI and +!PI. To express distances in arc units, divide
22;  by the radius of the globe expressed in the original units.
23;  For example, if the radius of the earth is 6371 km, divide
24;  the distance in km by 6371 to obtain the arc distance.   
25;    @param Az {in}{required}   The azimuth from Lon_lat0. The value is assumed to be in
26;  radians unless the keyword DEGREES is set.
27;
28; @keyword    DEGREES  Set this keyword to express all measurements and
29;  results in degrees.
30;
31; @returns
32; a (2, n) array containing the
33;       longitude / latitude of the resultings points. Values are in radians
34;       unless the keyword DEGREES is set.
35;
36; @file_comments
37;Formula from Map Projections - a working manual.  USGS paper
38;1395.  Equations (5-5) and (5-6).
39;
40; @examples
41;Lon_lat0 = [1.0, 2.0]; Initial point specified in radians
42;Arc_Dist = 2.0; Arc distance in radians
43;Az = 1.0; Azimuth in radians
44;Result = LL_ARC_DISTANCE(Lon_lat0, Arc_Dist, Az)
45;PRINT, Result
46;       2.91415    -0.622234
47;
48;IDL> lon0 = [-10, 20, 100]
49;IDL> lat0 = [0, -10, 45]
50;IDL> lon1 = [10, 60, 280]
51;IDL> lat1 = [0, 10, 45]
52;IDL> dist = map_npoints(lon0, lat0, lon1, lat1, azimuth = azi, /two_by_two)
53;IDL> earthradius = 6378206.4d0
54;IDL> res = ll_narcs_distances(lon0, lat0, dist/earthradius, azi, /degrees)
55;IDL> print, reform(res[0, *])
56;       10.000000       60.000000       280.00000
57;IDL> print, reform(res[1, *])
58;          1.1999280e-15       10.000000       45.000000
59;
60; @history
61;       Based on the IDL function ll_arc_distance.pro,v 1.11 2003/02/03
62; Sebastien Masson (smasson\@lodyc.jussieu.fr)
63;                  August 2005
64;-
65
66;+
67; @file_comments Return the [lon, lat] of the point a given arc distance
68;(-pi <= arc_dist <= pi),
69; and azimuth (az), from lon_lat0.
70;-
71;
72FUNCTION LL_NARCS_DISTANCES, lon0, lat0, arc_dist, az, DEGREES = degs
73;
74  IF n_elements(lon0) NE n_elements(lat0) $
75    OR n_elements(lon0) NE n_elements(arc_dist) $
76    OR n_elements(lon0) NE n_elements(az) THEN return, -1
77
78  cdist = cos(arc_dist[*])      ;Arc_Dist is always in radians.
79  sdist = sin(arc_dist[*])
80
81  if keyword_set(degs) then s = !dpi/180.0 else s = 1.0d0
82
83  ll = lat0[*] * s              ;To radians
84  sinll1 = sin(ll)
85  cosll1 = cos(ll)
86  azs = az[*] * s
87  phi = asin(sinll1 * cdist + cosll1 * sdist * cos(azs))
88  ll = lon0[*] * s              ;To radians
89  lam = ll + atan(sdist * sin(azs), $
90                  cosll1 * cdist - sinll1 * sdist * cos(azs))
91
92  zero = where(arc_dist eq 0, count)
93  IF count NE 0 THEN BEGIN
94    lam[zero] = lon0[zero]
95    phi[zero] = lat0[zero]
96  ENDIF
97
98  if keyword_set(degs) then return, transpose([[lam], [phi]]) / s $
99  ELSE return, transpose([[lam], [phi]])
100
101end
102
103
Note: See TracBrowser for help on using the repository browser.