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

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

modification of headers : mainly blanks around = sign for keywords in declaration of function and pro

  • 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.
[260]18; The edges must be given as in <proidl>PLOT</proidl> to draw the
[242]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
[325]33; by default: a 3d array(2,n^2,p) giving the center position of each
34; piece of the parallelograms
[59]35;
[325]36; if /ENDPOINTS : a 3d array(2,(n+1)^2,p) giving the edge positions
37; of each piece of the parallelograms
38;
[231]39; @uses
40; <pro>cutsegment</pro>
[59]41;
[125]42; @examples
[59]43;
[118]44; IDL> x0 = [2,6,2]
45; IDL> y0 = [0,2,6]
46; IDL> x1 = [3,8,4]
47; IDL> y1 = [4,4,6]
48; IDL> x2 = [1,6,4]
49; IDL> y2 = [5,6,8]
50; IDL> x3 = [0,4,2]
51; IDL> y3 = [1,4,8]
52; IDL> n = 4
53; IDL> splot, [0,10], [0,10], xstyle = 1, ystyle = 1,/nodata
54; 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]]
55; IDL> res=cutpar(x0, y0, x1, y1, x2, y2, x3, y3, n)
56; IDL> for i=0,2 do oplot, [res[0,*,i]], [res[1,*,i]], color = 20+10*i, psym = 1, thick = 3
[59]57;
[101]58; @history
59;           S. Masson (smasson\@lodyc.jussieu.fr)
[59]60;           July 5th, 2002
[118]61;
[231]62; @version
63; $Id$
[118]64;
[59]65;-
[327]66FUNCTION cutpar, x0, y0, x1, y1, x2, y2, x3, y3, n $
67               , ENDPOINTS=endpoints, ONSPHERE=onsphere
[114]68;
69  compile_opt idl2, strictarrsubs
70;
[59]71; is it a parallelogram?
72; eps = 1e-4
73; IF total(abs((x0+x2)/2-(x1+x3)/2) GE eps) GT 0 $
74;   OR total(abs((y0+y2)/2-(y1+y3)/2) GE eps) GT 0 $
75;   THEN stop; print, 'NOT a parallelogram'
76; x0(npar)
[125]77  npar = n_elements(x0)
[59]78; firstborder(2,n+keyword_set(endpoints),npar)
79  firstborder = cutsegment(x0, y0, x1, y1, n $
80                           , endpoints = endpoints, onsphere = onsphere)
81  thirdborder = cutsegment(x3, y3, x2, y2, n $
82                           , endpoints = endpoints, onsphere = onsphere)
83; res(2,n+keyword_set(endpoints),(n+keyword_set(endpoints))*npar)
84  res = cutsegment(firstborder[0, *, *], firstborder[1, *, *] $
85                   , thirdborder[0, *, *], thirdborder[1, *, *] $
86                   , n, endpoints = endpoints, onsphere = onsphere)
87; free memory
88  firstborder = -1
89  thirdborder = -1
90; reform the result
91  res = reform(res, 2, (n+keyword_set(endpoints))^2, npar, /overwrite)
92
93  RETURN, res
94END
Note: See TracBrowser for help on using the repository browser.