       Re: Interior of a polygon

• To: mathgroup at smc.vnet.net
• Subject: [mg28577] Re: Interior of a polygon
• From: dennisw555 at aol.com (DennisW555)
• Date: Sat, 28 Apr 2001 21:36:02 -0400 (EDT)
• References: <9cb9nr\$cjb@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```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

```

• Prev by Date: Q: Display::"initstate" -- what's that?
• Next by Date: Re: question of formatting with PaddedForm
• Previous by thread: Re: Interior of a polygon
• Next by thread: Re: Interior of a polygon