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

Last change on this file since 231 was 231, checked in by pinsard, 17 years ago

improvements/corrections of some *.pro headers

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