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