Geometry puzzler

Mike Fletcher mfletch at tpresence.com
Sun Nov 5 22:28:22 EST 2000


1) Polygon "inside" test (assumes convex polygons)
>From point, measure angle between each pair of points in the shell, summing
total.  Result which equals 360 degrees is a hit (i.e. the point is within
the convex shell)

1b) Polygon "inside" test (arbitrary polygons)
Take line from point to infiniti ( horizontal/vertical is the easiest),
count the number of times the line intersects the lines of the polygon, odd
== hit, even == miss.

See Graphics Gems for a better (more authoritative and useful) description
of the above and intersection testing for lines.

HTH,
Mike

-----Original Message-----
From: Paul Winkler [mailto:slinkp23 at yahoo.com]
Sent: Sunday, November 05, 2000 9:56 PM
To: python-list at python.org
Subject: Geometry puzzler
...
There are two basic but important things I can't figure out how to do:

1) Given any polygon, how can I test whether an arbitrary point lies
   inside that polygon?

2) Given two line segments, how can I find the coordinates of their
   intersection, if there is one? (easy for right angles, but I will
   often NOT have right angles.)
...




More information about the Python-list mailing list