# Inside Outside Test

 Register Blogs Members List Search Today's Posts Mark Forums Read

 November 13, 2008, 07:11 Inside Outside Test #1 James Guest   Posts: n/a Hi there, Could you please tell me, what is the most efficient method of determining if a given point (xp, yp) lies inside a given cell or not. The cell is a four sided polygon. The x, y coordinates of the four corners of the polygon are known. A method that is easily expandable to 3D at a later date would be preferable. Any snippets of pseudo-code would be greatly appreciated. Thanks

 November 13, 2008, 09:57 Oops! ERROR Re: Inside Outside Test #3 Ananda Himansu Guest   Posts: n/a Disregard the paragraph about the "alternative" method mentioned after steps (1) and (2), involving the four triangles A, B, C, D. I just thought of a simple counterexample where an exterior point is contained in two of the triangles. The rest of the post is correct, I coded this up (except for the hierarchical search tree) a few years ago. When using dot products with the normal vector to a given side, you can use the vertex at either end of the side as the local origin to form vectors. The entire algorithm sounds complex, but in practice it can be distilled down to very few lines of code.

 November 13, 2008, 22:01 Re: Inside Outside Test #4 inside-out Guest   Posts: n/a i have been thinking about this issue, and this is one method i am leaning towards. take the point in question, calculate its signed distance from all the sides of this polygon. If the point is inside all the signs of this signed distances will match. If this condision does not hold than it is outside of polygon. (this method shall work well with normal polygons, i am not sure how it will work with distorted polygons.

 November 14, 2008, 01:20 Re: Inside Outside Test #5 Markus Lummer Guest   Posts: n/a Hi James, have a look at http://www.ecse.rpi.edu/Homepages/wr...es/pnpoly.html Hope, this helps. Regards, Markus

 November 14, 2008, 02:31 Re: Inside Outside Test #6 inside-out Guest   Posts: n/a thank you for the link.

 November 18, 2008, 14:30 Re: Inside Outside Test #7 Munikrishna Nagaram Guest   Posts: n/a Ray-Casting Algorithm is widely used for inside/outside problem. Have a look at the paper: Milgram M.S., "Does a point lie inside a polygon?", Journal of Computational Physics, Volume 84, pp. 134-144, 1989.

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Fabio88 OpenFOAM Installation 21 June 2, 2010 03:01 piprus OpenFOAM Installation 22 February 25, 2010 14:43 allenzhao OpenFOAM Installation 127 January 30, 2009 20:08 Marios Vlad CFX 1 February 6, 2008 08:11 Steve FLUENT 0 April 17, 2003 12:37

All times are GMT -4. The time now is 14:42.