CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > General Forums > Main CFD Forum

To find whether a point lies inside or outside a curve defined by points

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   November 2, 2015, 06:40
Default To find whether a point lies inside or outside a curve defined by points
  #1
New Member
 
casper
Join Date: Sep 2015
Posts: 6
Rep Power: 11
casper is on a distinguished road
Hello all,

I have a closed curve defined by points and not equation. I have find if a point lies inside the curve or outside. Is there a way to do this without having to fit an equation to the curve?
Here by points I mean computational nodes and the points on the curve need not coincide with the nodes.
casper is offline   Reply With Quote

Old   November 2, 2015, 08:25
Default
  #2
New Member
 
Join Date: Sep 2012
Posts: 11
Rep Power: 14
JulianP is on a distinguished road
Hello,

have a look here: https://en.wikipedia.org/wiki/Point_in_polygon

In short: Draw an infinite horizontal line in one direction beginning at the point in question. Now, count how often this line intersects the edges of the polygon. If you get 0 or an even number, the point lies outside. If you get an odd number, the point lies inside.

You only have to think about what happens when your point lies on an edge of the polygon.
JulianP is offline   Reply With Quote

Old   November 3, 2015, 00:53
Default
  #3
New Member
 
casper
Join Date: Sep 2015
Posts: 6
Rep Power: 11
casper is on a distinguished road
Hey,

This would be easy if we had the equation of the curve. In my case, the curve is defined by points and cannot be very easily fit into an equation.
casper is offline   Reply With Quote

Old   November 3, 2015, 03:35
Default
  #4
New Member
 
Join Date: Sep 2012
Posts: 11
Rep Power: 14
JulianP is on a distinguished road
Hello casper,

this is a point-in-polygon test. In a polygon the discrete points are connected by edges, which are simple straight lines.

Have a look here: https://www.ics.uci.edu/~eppstein/161/960307.html You can find some pseudo-code there.

Don't think too complicated
JulianP is offline   Reply With Quote

Old   November 3, 2015, 04:48
Default
  #5
New Member
 
casper
Join Date: Sep 2015
Posts: 6
Rep Power: 11
casper is on a distinguished road
Thats awesome! Also the link has detailed description for the procedure.
Thanks Julian
casper is offline   Reply With Quote

Reply


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 Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[snappyHexMesh] .STL: non-closed manifold surface giulio.topazio OpenFOAM Meshing & Mesh Conversion 32 November 25, 2016 04:15
[snappyHexMesh] No layers in a small gap bobburnquist OpenFOAM Meshing & Mesh Conversion 6 August 26, 2015 10:38
block-structured mesh for t-junction Robert@cfd ANSYS Meshing & Geometry 20 November 11, 2011 05:59
Errors running allwmake in OpenFOAM141dev with WM_COMPILE_OPTION%3ddebug unoder OpenFOAM Installation 11 January 30, 2008 21:30
How to determine a point is inside a tetrahedral? G.P. Xia Main CFD Forum 16 January 12, 2000 12:15


All times are GMT -4. The time now is 23:56.