Changeset 125 for trunk/SRC/Interpolation/inquad.pro
- Timestamp:
- 07/06/06 16:10:25 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Interpolation/inquad.pro
r121 r125 1 1 ;+ 2 ; @file_comments to find if an (x,y) point is in a quadrilateral (x1,x2,x3,x4) 2 ; @file_comments 3 ; to find if an (x,y) point is in a quadrilateral (x1,x2,x3,x4) 3 4 ; 4 5 ; @categories grid manipulation … … 6 7 ; @param x {in}{required} 7 8 ; @param y {in}{required} 8 ; the coordinates of the point we want to know where it is. 9 ; Must be a scalar if / onsphere activated else can be scalar or array.9 ; the coordinates of the point we want to know where it is. 10 ; Must be a scalar if /ONSPHERE activated else can be scalar or array. 10 11 ; 11 12 ; @param x1 {in}{required} … … 17 18 ; @param x4 {in}{required} 18 19 ; @param y4 {in}{required} 19 ; the coordinates of the quadrilateral given in the CLOCKWISE order. 20 ; the coordinates of the quadrilateral given in the CLOCKWISE order. 20 21 ; Scalar or array. 21 22 ; 22 ; @keyword /DOUBLE use double precision to perform the computation23 ; 24 ; @keyword /ONSPHERE to specify that the quadilateral are on a sphere and23 ; @keyword DOUBLE use double precision to perform the computation 24 ; 25 ; @keyword ONSPHERE to specify that the quadilateral are on a sphere and 25 26 ; that teir coordinates are longitude-latitude coordinates. In this 26 27 ; case, est-west periodicity, poles singularity and other pbs 27 28 ; related to longitude-latitude coordinates are managed 28 ; automatically. 29 ; automatically. 29 30 ; 30 31 ; @keyword ZOOMRADIUS {default=4} … … 32 33 ; zoomradius degree where we look for the the quadrilateral which 33 34 ; contains the (x,y) point) used for the satellite projection 34 ; when / onsphere is activated.35 ; 4 seems to be the minimum which can be used. 35 ; when /ONSPHERE is activated. 36 ; 4 seems to be the minimum which can be used. 36 37 ; Can be increase if the cell size is larger than 5 degrees. 37 ; 38 ; @keyword /NOPRINT to suppress the print messages.38 ; 39 ; @keyword NOPRINT to suppress the print messages. 39 40 ; 40 41 ; @keyword NEWCOORD … … 45 46 ; quadrilateral number j with (0 <= j <= n_elements(x0)-1) 46 47 ; 47 ; @restrictions I think degenerated quadrilateral (e.g. flat of 48 ; twisted) is not work. This has to be tested. 49 ; 50 ; @examples 48 ; @restrictions 49 ; I think degenerated quadrilateral (e.g. flat of twisted) is not work. 50 ; This has to be tested. 51 ; 52 ; @examples 51 53 ; 52 54 ; IDL> x = 1.*[1, 2, 6, 7, 3] … … 70 72 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 71 73 ; August 2003 72 ; Based on Convert_clic_ij.pro written by Gurvan Madec 74 ; Based on Convert_clic_ij.pro written by Gurvan Madec 73 75 ; 74 76 ; @version $Id$ … … 100 102 x3 = x3 MOD 360 101 103 x4 = x4 MOD 360 102 ; save !map 104 ; save !map 103 105 save = {map:!map, x:!x, y:!y, z:!z, p:!p} 104 ; do a satellite projection 106 ; do a satellite projection 105 107 IF NOT keyword_set(zoomradius) THEN zoomradius = 4 106 108 map_set, y[0], x[0], 0, /satellite, sat_p = [1+zoomradius*20/6371.229, 0, 0], /noerase, /iso, /noborder 107 109 ; use normal coordinates to reject cells which are out of the projection. 108 tmp = convert_coord(x, y, /DATA, /TO_NORMAL, DOUBLE = double) 109 tmp1 = convert_coord(x1, y1, /DATA, /TO_NORMAL, DOUBLE = double) 110 tmp2 = convert_coord(x2, y2, /DATA, /TO_NORMAL, DOUBLE = double) 111 tmp3 = convert_coord(x3, y3, /DATA, /TO_NORMAL, DOUBLE = double) 112 tmp4 = convert_coord(x4, y4, /DATA, /TO_NORMAL, DOUBLE = double) 110 tmp = convert_coord(x, y, /DATA, /TO_NORMAL, DOUBLE = double) 111 tmp1 = convert_coord(x1, y1, /DATA, /TO_NORMAL, DOUBLE = double) 112 tmp2 = convert_coord(x2, y2, /DATA, /TO_NORMAL, DOUBLE = double) 113 tmp3 = convert_coord(x3, y3, /DATA, /TO_NORMAL, DOUBLE = double) 114 tmp4 = convert_coord(x4, y4, /DATA, /TO_NORMAL, DOUBLE = double) 113 115 ; remove cell which have one corner with coordinates equal to NaN 114 116 test = finite(tmp1[0, *]+tmp1[1, *]+tmp2[0, *]+tmp2[1, *] $ … … 150 152 ; 151 153 tmp1 = -1 & tmp2 = -1 & tmp3 = -1 & tmp4 = -1 152 ; remove cells which are obviously bad 154 ; remove cells which are obviously bad 153 155 test = (x1 GT x AND x2 GT x AND x3 GT x AND x4 GT x) $ 154 156 OR (x1 LT x AND x2 LT x AND x3 LT x AND x4 LT x) $ … … 179 181 ENDIF 180 182 ; 181 nquad = n_elements(good2) 183 nquad = n_elements(good2) 182 184 x1 = x1[good2] 183 185 y1 = y1[good2] … … 196 198 ; *((x-x2)*(y3-y2) GT (x3-x2)*(y-y2)) $ 197 199 ; *((x-x3)*(y4-y3) GT (x4-x3)*(y-y3)) $ 198 ; *((x-x4)*(y1-y4) GE (x1-x4)*(y-y4)) 200 ; *((x-x4)*(y1-y4) GE (x1-x4)*(y-y4)) 199 201 ; 200 202 ; computation of test without any do loop for ntofind points (x,y) and … … 202 204 ; test dimensions are (ntofind, nquad) 203 205 ; column i of test corresponds to the intersection of point i with all 204 ; quadirlateral. 205 ; row j of test corresponds to all the points localized in cell j 206 ; quadirlateral. 207 ; row j of test corresponds to all the points localized in cell j 206 208 test = $ 207 209 ; (x-x1) … … 277 279 ENDIF 278 280 return, -1 279 END 281 END 280 282 n_elements(found) GT ntofind:BEGIN 281 283 IF NOT keyword_set(noprint) THEN print, 'The point is in more than one cell' 282 END 284 END 283 285 ELSE: 284 286 ENDCASE 285 287 ENDIF ELSE BEGIN 286 ; if ntofind GT 1, found must be sorted 288 ; if ntofind GT 1, found must be sorted 287 289 ; i position of found. this corresponds to one x,y point 288 290 forsort = found MOD ntofind
Note: See TracChangeset
for help on using the changeset viewer.