To find whether a point lies inside or outside a curve defined by points
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. |
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. |
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. |
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 :) |
Thats awesome! Also the link has detailed description for the procedure.
Thanks Julian :D |
All times are GMT -4. The time now is 09:08. |