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

Last change on this file since 134 was 134, checked in by navarro, 18 years ago

change *.pro file properties (del eof-style, del executable, set keywords Id

  • Property svn:keywords set to Id
File size: 3.2 KB
RevLine 
[59]1;+
2;
[101]3; @file_comments
4; This function returns the longitude and latitude [lon, lat] of
[125]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.
[59]8;
[125]9; Formula from Map Projections - a working manual.  USGS paper
10; 1395.  Equations (5-5) and (5-6).
11;
[101]12; @categories Mapping, geography
[59]13;
[125]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
[101]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
[125]27;  the distance in km by 6371 to obtain the arc distance.
[59]28;
[125]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.
[59]32;
[125]33; @keyword DEGREES
34; Set this keyword to express all measurements and results in degrees.
35;
[101]36; @returns
[125]37; a (2, n) array containing the longitude/latitude of the resultings points.
38; Values are in radians unless the keyword DEGREES is set.
[59]39;
[125]40; @examples
[121]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
[101]46;       2.91415    -0.622234
[59]47;
[125]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, *])
[101]56;       10.000000       60.000000       280.00000
[125]57; IDL> print, reform(res[1, *])
58;           1.1999280e-15       10.000000       45.000000
[59]59;
[101]60; @history
[59]61;       Based on the IDL function ll_arc_distance.pro,v 1.11 2003/02/03
[101]62; Sebastien Masson (smasson\@lodyc.jussieu.fr)
[59]63;                  August 2005
[118]64;
65; @version $Id$
66;
[59]67;-
68;
69FUNCTION LL_NARCS_DISTANCES, lon0, lat0, arc_dist, az, DEGREES = degs
70;
[114]71  compile_opt idl2, strictarrsubs
72;
73;
[59]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)
[125]93  IF count NE 0 THEN BEGIN
[59]94    lam[zero] = lon0[zero]
95    phi[zero] = lat0[zero]
[125]96  ENDIF
[59]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.