Re: testing if a point is inside a polygon
- To: mathgroup at smc.vnet.net
- Subject: [mg96242] Re: testing if a point is inside a polygon
- From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
- Date: Tue, 10 Feb 2009 05:49:47 -0500 (EST)
- Organization: The Open University, Milton Keynes, UK
- References: <gmp0mt$btn$1@smc.vnet.net>
In article <gmp0mt$btn$1 at smc.vnet.net>, Mitch Murphy <mitch at lemma.ca> wrote: > is there a way to test whether a point is inside a polygon? ie. > > PointInsidePolygonQ[point_,polygon_] -> True or False [snip] You could have a look at the different algorithms presented in Paul Bourke's paper [1], pick up one of your liking, then code it from the provided C source code to Mathematica syntax. How the algorithms work, their benefits and draw backs, as well as tested C code and diagrams, are neatly presented. Depending of your level of familiarity with Mathematica programming, it might be easier to translate the C syntax into equivalent Mathematica procedural constructs, test the code, and then convert it into fast functional Mathematica code. If you have performance issues or troubles converting procedural code (fast in C, but slow in Mathematica) into functional code (fast in Mathematica), people in MathGroup will help you to improve performances or overcome coding issues. Regards, --Jean-Marc [1] Paul Bourke, "Determining If A Point Lies On The Interior Of A Polygon", http://local.wasp.uwa.edu.au/~pbourke/geometry/insidepoly/