RE: Point inside a plygon?
- To: mathgroup at smc.vnet.net
- Subject: [mg25279] RE: [mg25239] Point inside a plygon?
- From: "David Park" <djmp at earthlink.net>
- Date: Tue, 19 Sep 2000 03:45:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Adriano, Here is one method. First consider the question whether a point is inside a triangle. 1) Get the formula for the area of a triangle given the three vertices. 2) Calculate the area of the triangle. 3) Use the point as a new vertix and calculate the areas of the three triangles formed by the point and the three sides of the original triangle. 4) If the sum of the areas of those three triangles is the same as the area of the original triangle, then the point is within the triangle. If the sum is greater, the point is outside the triangle. Now divide your polygon into triangles, by picking one vertix and drawing lines to each of the other vertices. Use the above procedure to see if the point is within any of the triangles. It would be interesting to learn if there are other methods. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > -----Original Message----- > From: Adriano Moreira [mailto:adriano at dsi.uminho.pt] To: mathgroup at smc.vnet.net > 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