I want to determine whether a point is within a non convex ngon (2d obvs) using the project a ray from outside and count the intersections method.
I'm lazy and don't want to put the 500(possible exaggeration) nodes required to do the sums into a graph by hand so I'm hoping there's a built in method I haven't found yet (I don't really know the libraries)
Before anyone suggests the line trace nodes I don't think they work in this context as there is nothing to trace against
Ta
Replies
The idea is that you trace a line from a point outside the spline to a target point that you want to query and assume that if the trace intersects an odd number of edges the target point must be inside the shape
I've ended up implementing the answer by Gareth Rees on this page (first discarding points outside the bounding rectangle of my spline for speed's sake)
https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect
There are some potential hiccups around parallel or colinear lines but it works fine for my purposes since I am only interested in successful intersections
I've not tried this with a lot of spline points yet (100+) and I can see it getting a bit chuggy - it's not a realistic use case but would still be nice to have something that could cope
Is this for spawning instanced meshes? Because then there is a more efficient way of doing this.
What's the more efficient way though? Might well come in handy for something
It emerges I need to trace from more than one start point for this to be reliable since there are situations where it's unable to remove points