View Full Version : point in polygon?

04-17-2009, 09:54 AM
Is there a function which determines whether a single 2D point is within the region of a bounded polygon (specified by an array of 2D points)? I need to do something like this:

poly = [[1.,1.],[2.,2.],[1.,3.],[0.,2.]]
point = [1.5,2.75]
; IF POINT_IN_POLY(poly, point) THEN PRINT, 'True' ELSE PRINT, 'False'

I could write my own, but don't want to reinvent the wheel.

04-20-2009, 10:59 AM
there is wave/lib/user/examples/pntnhull.pro which is an
incomplete attempt at an n-d convex hull routine, but it
works just fine for n<3

04-20-2009, 01:35 PM
No such file in that folder for WAVE 8.0 or WAVE 9.0.

04-20-2009, 06:59 PM
it is in version 9.01 but will work in version 9.00;
you can get pntnhull.pro from
at the link entitled
Architecture Independent (PV-WAVE .pro files only)

04-21-2009, 09:34 AM
Thanks for the reference, but I won't be using it. I need to detects points in non-convex hulls. I found a work-around by converting this MATLAB code to PV-WAVE:


Works great and executes fast. Even returns points on edge if you want.