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
RevLine 
[59]1;+
2;
[125]3; @file_comments
4; cut p parallelogram(s) into p*n^2 parallelograms
[59]5;
[101]6; @categories basic work
[59]7;
[118]8; @param x0 {in}{required}
[125]9; @param y0 {in}{required}
[118]10; @param x1 {in}{required}
[125]11; @param y1 {in}{required}
[118]12; @param x2 {in}{required}
[125]13; @param y2 {in}{required}
[118]14; @param x3 {in}{required}
[125]15; @param y3 {in}{required}
[118]16; 1d arrays of p elements, giving the edge positions. The
[125]17;       edges must be given as in plot to draw the parallelogram. (see
[59]18;       example).
19;
[118]20; @param n {in}{required} each parallelogram will be cutted in n^2 pieces
[59]21;
[125]22; @keyword ENDPOINTS see outputs
[118]23;
[125]24; @keyword ONSPHERE to specify that the points are located on a
[59]25;         sphere. In this case, x and y corresponds to longitude and
26;         latitude in degrees.
27;
[101]28; @returns
[125]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
[59]33;
[101]34; @uses cutsegment.pro
[59]35;
[125]36; @examples
[59]37;
[118]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
[59]51;
[101]52; @history
53;           S. Masson (smasson\@lodyc.jussieu.fr)
[59]54;           July 5th, 2002
[118]55;
56; @version $Id$
57;
[59]58;-
[125]59FUNCTION cutpar, x0, y0, x1, y1, x2, y2, x3, y3, n, ENDPOINTS = endpoints, ONSPHERE = onsphere
[114]60;
61  compile_opt idl2, strictarrsubs
62;
[59]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)
[125]69  npar = n_elements(x0)
[59]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.