source: trunk/SRC/Interpolation/cutpar.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: 2.6 KB
Line 
1;+
2;
3; @file_comments
4; cut p parallelogram(s) into p*n^2 parallelograms
5;
6; @categories basic work
7;
8; @param x0 {in}{required}
9; @param y0 {in}{required}
10; @param x1 {in}{required}
11; @param y1 {in}{required}
12; @param x2 {in}{required}
13; @param y2 {in}{required}
14; @param x3 {in}{required}
15; @param y3 {in}{required}
16; 1d arrays of p elements, giving the edge positions.
17; The edges must be given as in plot to draw the parallelogram. (see example).
18;
19; @param n {in}{required}
20; each parallelogram will be cutted in n^2 pieces
21;
22; @keyword ENDPOINTS
23; see outputs
24;
25; @keyword ONSPHERE
26; to specify that the points are located on a
27; sphere. In this case, x and y corresponds to longitude and
28; latitude in degrees.
29;
30; @returns
31;  - default: a 3d array(2,n^2,p) giving the center position of each
32;  piece of the parallelograms
33;  - if /ENDPOINTS : a 3d array(2,(n+1)^2,p) giving the edge positions
34;  of each piece of the parallelograms
35;
36; @uses cutsegment.pro
37;
38; @examples
39;
40; IDL> x0 = [2,6,2]
41; IDL> y0 = [0,2,6]
42; IDL> x1 = [3,8,4]
43; IDL> y1 = [4,4,6]
44; IDL> x2 = [1,6,4]
45; IDL> y2 = [5,6,8]
46; IDL> x3 = [0,4,2]
47; IDL> y3 = [1,4,8]
48; IDL> n = 4
49; IDL> splot, [0,10], [0,10], xstyle = 1, ystyle = 1,/nodata
50; IDL> for i=0,2 do oplot, [x0[i],x1[i],x2[i],x3[i],x0[i]],[y0[i],y1[i],y2[i],y3[i],y0[i]]
51; IDL> res=cutpar(x0, y0, x1, y1, x2, y2, x3, y3, n)
52; IDL> for i=0,2 do oplot, [res[0,*,i]], [res[1,*,i]], color = 20+10*i, psym = 1, thick = 3
53;
54; @history
55;           S. Masson (smasson\@lodyc.jussieu.fr)
56;           July 5th, 2002
57;
58; @version $Id$
59;
60;-
61FUNCTION cutpar, x0, y0, x1, y1, x2, y2, x3, y3, n, ENDPOINTS = endpoints, ONSPHERE = onsphere
62;
63  compile_opt idl2, strictarrsubs
64;
65; is it a parallelogram?
66; eps = 1e-4
67; IF total(abs((x0+x2)/2-(x1+x3)/2) GE eps) GT 0 $
68;   OR total(abs((y0+y2)/2-(y1+y3)/2) GE eps) GT 0 $
69;   THEN stop; print, 'NOT a parallelogram'
70; x0(npar)
71  npar = n_elements(x0)
72; firstborder(2,n+keyword_set(endpoints),npar)
73  firstborder = cutsegment(x0, y0, x1, y1, n $
74                           , endpoints = endpoints, onsphere = onsphere)
75  thirdborder = cutsegment(x3, y3, x2, y2, n $
76                           , endpoints = endpoints, onsphere = onsphere)
77; res(2,n+keyword_set(endpoints),(n+keyword_set(endpoints))*npar)
78  res = cutsegment(firstborder[0, *, *], firstborder[1, *, *] $
79                   , thirdborder[0, *, *], thirdborder[1, *, *] $
80                   , n, endpoints = endpoints, onsphere = onsphere)
81; free memory
82  firstborder = -1
83  thirdborder = -1
84; reform the result
85  res = reform(res, 2, (n+keyword_set(endpoints))^2, npar, /overwrite)
86
87  RETURN, res
88END
Note: See TracBrowser for help on using the repository browser.