<<prev file | next file >>    view single page | view frames    summary: fields | routine    details: routine

Interpolation/

inquad.pro

to find if an (x,y) point is in a quadrilateral (x1,x2,x3,x4)

topinquad grid manipulation

result = inquad(x, y, x1, y1, x2, y2, x3, y3, x4, y4, ONSPHERE=ONSPHERE, DOUBLE=DOUBLE, ZOOMRADIUS=ZOOMRADIUS, NOPRINT=NOPRINT, NEWCOORD=NEWCOORD)

Return value

a n element vector. Where n is the number of elements of x. res[i]=j means that the point number i is located in the quadrilateral number j with (0 <= j <= n_elements(x0)-1)

Parameters

x        in required

the coordinates of the point we want to know where it is. Must be a scalar if /onsphere activated else can be scalar or array.

y       

x1        in required

the coordinates of the quadrilateral given in the CLOCKWISE order. Scalar or array.

y1       

x2       

y2       

x3       

y3       

x4       

y4       

Keywords

ONSPHERE       

to specify that the quadilateral are on a sphere and that teir coordinates are longitude-latitude coordinates. In this case, est-west periodicity, poles singularity and other pbs related to longitude-latitude coordinates are managed automatically.

DOUBLE       

use double precision to perform the computation

ZOOMRADIUS       

:the zoom (circle centred on the (x,y) with a radius of zoomradius degree where we look for the the quadrilateral which; contains the (x,y) point) used for the satellite projection when /onsphere is activated. Default is 4 and seems to be the minimum which can be used. Can be increase if the cell size is larger than 5 degrees.

NOPRINT       

to suppress the print messages.

NEWCOORD       

Examples

res = inquad(x, y, x1, y1, x2, y2, x3, y3, x4, y4) x = 1.*[1, 2, 6, 7, 3] y = 1.*[1, 3, 3, 4, 7] x1 = 1.*[0,4,2] y1 = 1.*[1,4,8] x2 = 1.*[1,6,4] y2 = 1.*[5,6,8] x3 = 1.*[3,8,4] y3 = 1.*[4,4,6] x4 = 1.*[2,6,2] y4 = 1.*[0,2,6] splot, [0,10], [0,10], xstyle = 1, ystyle = 1,/nodata for i=0,2 do oplot, [x4[i],x1[i],x2[i],x3[i],x4[i]],[y4[i],y1[i],y2[i],y3[i],y4[i]] oplot, x, y, color = 20, psym = 1, thick = 2 print, inquad(x, y, x1, y1, x2, y2, x3, y3, x4, y4) On a sphere see clickincell.pro...

Version history

History

Sebastien Masson (smasson@lodyc.jussieu.fr) August 2003 Based on Convert_clic_ij.pro written by Gurvan Madec

Known issues

Restrictions

I think degenerated quadrilateral (e.g. flat of twisted) is not work. This has to be tested.
Produced by IDLdoc 2.0.