source: trunk/Interpolation/cutpar.pro @ 59

Last change on this file since 59 was 59, checked in by pinsard, 18 years ago

upgrade of Interpolation according to cerbere.lodyc.jussieu.fr: /usr/home/smasson/SAXO_RD/

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1;+
2; NAME: cutpar
3;
4; PURPOSE: cut p parallelogram(s) into p*n^2 parallelograms
5;
6; CATEGORY: basic work
7;
8; CALLING SEQUENCE:res = cutpar(x0, y0, x1, y1, x2, y2, x3, y3, n)
9;
10; INPUTS:
11;       x0,y0 1d arrays of p elements, giving the edge positions. The
12;       edges must be given as in plot to traw the parallelogram. (see
13;       example).
14;       n: each parallelogram will be cutted in n^2 pieces
15;
16; KEYWORD PARAMETERS:
17;
18;         /endpoints: see outputs
19;
20;         /onsphere: to specify that the points are located on a
21;         sphere. In this case, x and y corresponds to longitude and
22;         latitude in degrees.
23;
24; OUTPUTS:
25;        -defaut: 3d array(2,n^2,p) giving the center position of each
26;        piece of the parallelograms
27;        -/endpoints: 3d array(2,(n+1)^2,p) giving the edge positions
28;        of each piece of the parallelograms
29;
30; COMMON BLOCKS: no
31;
32; SIDE EFFECTS: need cutsegment.pro
33;
34; RESTRICTIONS: ?
35;
36; EXAMPLE:
37;
38; x0 = [2,6,2]
39; y0 = [0,2,6]
40; x1 = [3,8,4]
41; y1 = [4,4,6]
42; x2 = [1,6,4]
43; y2 = [5,6,8]
44; x3 = [0,4,2]
45; y3 = [1,4,8]
46; n = 4
47; splot, [0,10], [0,10], xstyle = 1, ystyle = 1,/nodata
48; 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; res=cutpar(x0, y0, x1, y1, x2, y2, x3, y3, n)
50; for i=0,2 do oplot, [res[0,*,i]], [res[1,*,i]], color = 20+10*i, psym = 1, thick = 3
51;
52; MODIFICATION HISTORY:
53;           S. Masson (smasson@lodyc.jussieu.fr)
54;           July 5th, 2002
55;-
56FUNCTION cutpar, x0, y0, x1, y1, x2, y2, x3, y3, n, endpoints = endpoints, onsphere = onsphere
57; is it a parallelogram?
58; eps = 1e-4
59; IF total(abs((x0+x2)/2-(x1+x3)/2) GE eps) GT 0 $
60;   OR total(abs((y0+y2)/2-(y1+y3)/2) GE eps) GT 0 $
61;   THEN stop; print, 'NOT a parallelogram'
62; x0(npar)
63  npar = n_elements(x0)
64; firstborder(2,n+keyword_set(endpoints),npar)
65  firstborder = cutsegment(x0, y0, x1, y1, n $
66                           , endpoints = endpoints, onsphere = onsphere)
67  thirdborder = cutsegment(x3, y3, x2, y2, n $
68                           , endpoints = endpoints, onsphere = onsphere)
69; res(2,n+keyword_set(endpoints),(n+keyword_set(endpoints))*npar)
70  res = cutsegment(firstborder[0, *, *], firstborder[1, *, *] $
71                   , thirdborder[0, *, *], thirdborder[1, *, *] $
72                   , n, endpoints = endpoints, onsphere = onsphere)
73; free memory
74  firstborder = -1
75  thirdborder = -1
76; reform the result
77  res = reform(res, 2, (n+keyword_set(endpoints))^2, npar, /overwrite)
78
79  RETURN, res
80END
Note: See TracBrowser for help on using the repository browser.