MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Interior of a polygon

  • To: mathgroup at smc.vnet.net
  • Subject: [mg28578] Re: Interior of a polygon
  • From: Andrzej Kozlowski <andrzej at tuins.ac.jp>
  • Date: Sat, 28 Apr 2001 21:36:03 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Well, yes but we all know this. This was discussed on this list in detail
last year, and exactly the same method was described by a number of
different people. But this was not the point of the question this time. THe
point was to find all the points which have integer coordinates which lie
inside. Your suggestion simply gives the most obvious and probably
inefficient method which I referred to as "brute force" and which Mariusz
Jankowski (who asked the original question) had known about already before
he sent his message to the mathgroup.

Andrzej

on 01.4.28 8:47 AM, DennisW555 at dennisw555 at aol.com wrote:

> To find if a point is inside a polygon simply start at one vertex and
> accumulate the angles from the point to each sucessive vertex, all the way
> around to that starting vertex.  Keep track of the sense, as some will be
> negative angles and some positive.  If the magnitude of the sum of angles is 2
> Pi the point is inside.  If the sum is zero the point is outside.  I set the
> decision threshold at Pi for simplicity.  With this method the polygon does
> not
> need to be convex.  I pretend the polygon points are in the xy plane and take
> cross products between successive vectors from the point to the vertex.  Then
> the magnitude of the sum of the z components of the cross products is the
> quantity to test. To do this a vertex at coordinates {x,y} becomes {x,y,0},
> likewise for the point.
> 
> I hope this helps,
> 
> Dennis Wangsness
> 

-- 
Andrzej Kozlowski
Toyama International University
JAPAN

http://platon.c.u-tokyo.ac.jp/andrzej/
http://sigma.tuins.ac.jp/



  • Prev by Date: RE: question of formatting with PaddedForm
  • Next by Date: Re: question of formatting with PaddedForm
  • Previous by thread: Re: Interior of a polygon
  • Next by thread: Mathematica and the Internet