Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2000
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2000

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

Search the Archive

Re: Point inside a polygon?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg25426] Re: Point inside a polygon?
  • From: Avi Mintz <Avi.Mintz at nsc.com>
  • Date: Fri, 29 Sep 2000 01:07:42 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Adriano Moreira wrote:
> 
> Hi,
> 
> I need a routine to check if a point is inside or outside a polygon
> (simple polygon non self-intersecting).
> Any help appreciated.
> 
> Adriano Moreira

that is a "famous" question for interviews of new imployees.

take a straight line from the point to infinity (or at least beyond the
polygon)
 - it is usually best if that line is parralel to one of the axis
then count how many times the new line intersects with lines of the
polygon - an even number means its outside,
an odd number means its inside

avi


  • Prev by Date: Re: extracting elements from a list?
  • Next by Date: Re: extracting elements from a list?
  • Previous by thread: extracting common items from a list
  • Next by thread: InequalitySolve?