To find a point inside a polygon

Mike Fletcher mfletch at tpresence.com
Wed Jan 26 10:54:37 EST 2000


Hmm, something like:

def inside( point, array ):
	draw line to infinity from point, counting intersections
	return intersections % 2 # odd/even

I think graphic gems has a decent implementation.  You have to figure out
whether on-edge means inside or outside.  I seem to recall that there's some
special casing for edges which are equal to your test ray (I think it's
considered a "hit"), but it's been a long time since I idly browsed that
stuff.

HTH,
Mike

-----Original Message-----
From: David Yeung [mailto:dyeung at ust.hk]
Sent: Wednesday, January 26, 2000 10:10 AM
To: python-list at python.org
Subject: To find a point inside a polygon


Does anyone know if any python implementation for finding whether a point
is inside a polygon? E.g., by giving a point(x,y) and an array of polygon's
points (x0,y0,x1,y1,x2,y2,...), it returns true or false to tell if the 
given (x,y) is inside the polygon.

Thanks

david
-- 
http://www.python.org/mailman/listinfo/python-list




More information about the Python-list mailing list