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

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

some improvements and corrections in some .pro file according to
aspell and idldoc log file

  • Property svn:keywords set to Id
File size: 3.2 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; Formula from Map Projections - a working manual.  USGS paper
10; 1395. Equations (5-5) and (5-6).
11;
12; @categories Mapping, geography
13;
14; @param Lon0 {in}{required}
15; An array containing the longitude of the starting point.
16; Values are assumed to be in radians unless the keyword DEGREES is set.
17;
18; @param Lat0 {in}{required}
19; An array containing the latitude of the starting point.
20; Values are assumed to be in radians unless the keyword DEGREES is set.
21;
22; @param Arc_Dist {in}{required}
23; The arc distance from Lon_lat0. The value must be between
24; -!PI and +!PI. To express distances in arc units, divide
25;  by the radius of the globe expressed in the original units.
26;  For example, if the radius of the earth is 6371 km, divide
27;  the distance in km by 6371 to obtain the arc distance.
28;
29; @param Az {in}{required}
30; The azimuth from Lon_lat0. The value is assumed to be in
31; radians unless the keyword DEGREES is set.
32;
33; @keyword DEGREES
34; Set this keyword to express all measurements and results in degrees.
35;
36; @returns
37; a (2, n) array containing the longitude/latitude of the resultings points.
38; Values are in radians unless the keyword DEGREES is set.
39;
40; @examples
41; IDL> Lon_lat0 = [1.0, 2.0]; Initial point specified in radians
42; IDL> Arc_Dist = 2.0; Arc distance in radians
43; IDL> Az = 1.0; Azimuth in radians
44; IDL> Result = LL_ARC_DISTANCE(Lon_lat0, Arc_Dist, Az)
45; IDL> 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; @version $Id$
66;
67;-
68;
69FUNCTION LL_NARCS_DISTANCES, lon0, lat0, arc_dist, az, DEGREES = degs
70;
71  compile_opt idl2, strictarrsubs
72;
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
Note: See TracBrowser for help on using the repository browser.