comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Point inside/outside a polygon?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Point inside/outside a polygon? [message #26241 is a reply to message #26180] Mon, 13 August 2001 08:12 Go to previous messageGo to previous message
Andy Loughe is currently offline  Andy Loughe
Messages: 174
Registered: November 1995
Senior Member
Here is some ROI code I have collected over the years...

; Define and draw an oddly shaped polygon.
x = [ .5, .7, .8, .8, .6, .5, .5]
y = [ 0., .2, .1, .9, .7, .7, 0.]
z = [ 0., 0., 0., 0., 0., 0., 0.]
plot, x, y, /nodata, xrange=[0,1], yrange=[-.2,1]
plots, x, y, thick=5

roi = Obj_New('IDLanROI', x, y, z)

; Point outside the polygon = 0 (CASE #1)
x1 = .6 & y1=.05 & z1=0.0
xyouts, x1, y1, '1', chars=1.25, align=.5
print, roi->ContainsPoints(x1, y1, z1)

; Point inside the polygon = 1 (CASE #2)
x1 = .78 & y1=.85 & z1=0.0
xyouts, x1, y1, '2', chars=1.25, align=.5
print, roi->ContainsPoints(x1, y1, z1)

; Point on an edge of the polygon = 2 (CASE #3)
x1 = .8 & y1=.5 & z1=0.0
xyouts, x1, y1, '3', chars=1.25, align=.5
print, roi->ContainsPoints(x1, y1, z1)

; Point on a vertex of the polygon = 3 (CASE #4)
x1 = .7 & y1=.2 & z1=0.0
xyouts, x1, y1, '4', chars=1.2, align=.5
print, roi->ContainsPoints(x1, y1, z1)

Obj_Destroy, roi


--
Andrew Loughe =====================================================
NOAA/OAR/FSL/AD R/FS5 | email: loughe@fsl.noaa.gov
325 Broadway | wwweb: www-ad.fsl.noaa.gov/users/loughe
Boulder, CO 80305-3328 | phone: 303-497-6211 fax: 303-497-6301
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Discussion on global variables in IDL
Next Topic: visualizing data in 3-D

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Mar 21 15:01:40 PDT 2026

Total time taken to generate the page: 1.04623 seconds