source: trunk/SRC/Interpolation/cutpar.pro @ 114

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

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