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

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

improvements/corrections of some *.pro headers + replace some message by some report

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