home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!elroy.jpl.nasa.gov!news.claremont.edu!ucivax!orion.oac.uci.edu!cerritos.edu!arizona.edu!arizona!amethyst!organpipe.uug.arizona.edu!news
- Newsgroups: comp.programming
- Subject: Re: Deciding point-in-polygon: A new idea.
- Message-ID: <1992Aug31.050118.29863@organpipe.uug.arizona.edu>
- From: dave@cs.arizona.edu (Dave Schaumann)
- Date: 31 Aug 92 05:01:18 GMT
- Reply-To: dave@cs.arizona.edu (Dave Schaumann)
- Sender: news@organpipe.uug.arizona.edu
- References: <schnitzi.715219193@eola.cs.ucf.edu>
- Distribution: comp
- Organization: University of Arizona
- In-Reply-To: schnitzi@cs.ucf.edu (Mark Schnitzius)
- Lines: 38
-
- In article <schnitzi.715219193@eola.cs.ucf.edu>, schnitzi@cs (Mark Schnitzius) writes:
- >Compute the area of the polygon in question (this is a well
- >known and simple procedure).
-
- Well, so is an easy algorithm for finding out if a point is inside
- a polygon, but never mind...
-
- >Now consider the polygon formed
- >by adding the point in question as another vertice, anywhere
- >in the original list of vertices. If the area of this new
- >polygon is greater than the original, the point is outside
- >the polygon. If less, it is inside.
- >
- >My question: will it work?
-
- No. Here's an example where you will get the wrong answer:
-
- A (placed just outside the B-C line)
- .
- B.---------------------.C
- | |
- | |
- | |
- | |
- D.---------------------.E
-
- Since I can choose which vertices to insert A between, I choose D and E.
- Although the object is no longer a simple polygon, it clearly encloses
- less area than the original, and thus your algorithm would say that A
- is inside, even though it is not.
-
- To fix this, you need to add A between the vertices whose edge it is
- nearest to. I haven't checked it, but I wouldn't be surprised to find
- that you're now doing as much (if not more) work as the traditional
- "shoot a ray and count the intersections" method.
-
- --
- Dave Schaumann dave@cs.arizona.edu
-