home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!rutgers!uwvax!jalapeno.cs.wisc.edu!bach
- From: bach@jalapeno.cs.wisc.edu (Eric Bach)
- Newsgroups: sci.math
- Subject: Re: Polygon point enclosure
- Message-ID: <1992Aug27.185740.21083@cs.wisc.edu>
- Date: 27 Aug 92 18:57:40 GMT
- References: <7122@bigbird.hri.com.hri.com> <1992Aug26.235700.16224@infodev.cam.ac.uk> <thompson.714934114@daphne.socsci.umn.edu>
- Sender: news@cs.wisc.edu (The News)
- Organization: University of Wisconsin, Madison -- Computer Sciences Dept.
- Lines: 29
-
- >>> I'm looking for a method to determine if a point is enclosed
- >>> by a polygon. Any help would be greatly appreciated.
- >
- >>Well, here's one approach. Imagine a ray (=half-line) coming off from the point
- >>in some direction. Count how many of the sides of the polygon it goes through.
- >>(If it goes *along* any of those sides you're in trouble and should try another
- >>direction.) If it's an odd number the point is inside the polygon; if it's an
- >>even number the point is outside the polygon.
- >
- >This algorithm is in _Algorithms_ by Robert Sedgewick, Addison-Wesley
- >(1983), pp 315-318. (I believe there is a second edition out, but I
- >don't have it.)
-
- The last time I taught the algorithms course, I discovered
- that the algorithm in the second edition (p. 354) fails on
- an equilateral triangle whose vertices are the 3 roots of
- unity. (Are you listening, Bob?) Not exactly "general position,"
- but...
-
- In response to this, I presented another algorithm, based
- on computing "pseudo winding numbers" using the "pseudo angle"
- defined on p. 353. The rough idea is that you only care about
- the homology class of your cycle, and this can be figured out
- using O(n) rational operations. I am curious if this is "known"
- (i.e. written up somewhere). Next time it would be nice to give a
- reference!
-
- -Eric Bach
- bach@cs.wisc.edu
-