home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: sci.math
- Path: sparky!uunet!cs.utexas.edu!sun-barr!ames!think.com!linus!linus.mitre.org!gauss!bs
- From: bs@gauss.mitre.org (Robert D. Silverman)
- Subject: Re: Polygon point enclosure
- Message-ID: <1992Aug27.180024.2843@linus.mitre.org>
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: gauss.mitre.org
- Organization: Research Computer Facility, MITRE Corporation, Bedford, MA
- References: <7122@bigbird.hri.com.hri.com> <1992Aug26.235700.16224@infodev.cam.ac.uk> <thompson.714934114@daphne.socsci.umn.edu>
- Date: Thu, 27 Aug 1992 18:00:24 GMT
- Lines: 35
-
- In article <thompson.714934114@daphne.socsci.umn.edu> thompson@atlas.socsci.umn.edu writes:
- :gjm11@cus.cam.ac.uk (G.J. McCaughan) writes:
- :
- :>In article <7122@bigbird.hri.com.hri.com>, mps@sparc68.hri.com (Mark Stockley) writes:
- :
- :>> 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
-
- I have a question.
-
- I will assume that the polygon is given by a set of points.
-
- Counting how many sides it intersects seems to require computing the
- equation for the line containing each side and determining whether
- the ray intersects the line between the two points. This requires
- computing O(N) equations and intersections.
-
- Why is this any faster than simply representing the interior of
- the polygon as a set of linear inequalities and simply checking
- whether the desired point satisfies each inequality?? This is also O(N).
- This is essentially equivalent to whether a solution is feasible
- in linear programming.
- --
- Bob Silverman
- These are my opinions and not MITRE's.
- Mitre Corporation, Bedford, MA 01730
- "You can lead a horse's ass to knowledge, but you can't make him think"
-