home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.programming
- Path: sparky!uunet!mcsun!Germany.EU.net!olymp!uran!hermann
- From: hermann@uran.informatik.uni-bonn.de (Hermann Stamm)
- Subject: Re: Deciding point-in-polygon: A new idea
- Message-ID: <1992Aug31.083543.27938@olymp.informatik.uni-bonn.de>
- Sender: usenet@olymp.informatik.uni-bonn.de
- Reply-To: hermann@uran.informatik.uni-bonn.de (Hermann Stamm)
- Organization: Praktische Informatik III
- Date: Mon, 31 Aug 1992 08:35:43 GMT
- Lines: 63
-
- |
- | Article: 1696 of comp.programming
- | Path: olymp!Sirius.dfn.de!darwin.sura.net!wupost!cs.utexas.edu!sun-barr!olivea!uunet!peora!tarpit!cs.ucf.edu!schnitzi
- | From: schnitzi@cs.ucf.edu (Mark Schnitzius)
- | Newsgroups: comp.programming
- | Subject: Deciding point-in-polygon: A new idea.
- | Message-ID: <schnitzi.715219193@eola.cs.ucf.edu>
- | Date: 30 Aug 92 23:59:53 GMT
- | Sender: news@cs.ucf.edu (News system)
- | Distribution: comp
- | Organization: University of Central Florida
- | Lines: 15
- |
- | How about this:
- |
- | Compute the area of the polygon in question (this is a well
- | known and simple procedure). 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?
- |
- |
- | Mark Schnitzius
- | schnitzi@eola.csu.ucf.edu
- | Univ. of Central Florida
- |
-
- This will not work! The area can be smaller even if the added
- point lies outside the polygon, but there is a more simple
- proof, that this can't be right:
-
- The area of Polygon (x1,y1),(x2,y2), ... , (xn,yn) is given by
-
- A=x[n]*y[1]-y[n]*x[1];
- for(i=1; i<n; i++)
- A+=(x[i]*y[i+1]-y[i]*x[i+1]);
- A/=2;
-
- If you are allowed to insert the new point (x,y) where you like, then
- insert (x,y) always between (x1,y1) and (x2,y2).
-
- The only change in the above sum will then depend only on
- (x1,y1), (x2,y2) and (x,y), and thus will be computable in constant time,
- but you can't look at the whole input in constant time, and the rest of the
- lines can either force (x,y) to lie inside or not. contradiction!
-
- Here the example to the first proposition:
-
- P4 P3 Q
-
-
- P1 P2
- --------
- x
-
- The area of Square P1,P2,P3,P4 is x*x, the area of polygon
- P1,Q,P2,P3,P4 is roughly x*x/2 !
-
-
- Hermann.
-