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