Given some set of nodes within a convex hull, assume the domain contains one or more concave areas:
where blue dots are points, and the black li
Since my question is seeming to continue to get a decent amount of activity, I wanted to follow up with the application that I'm currently using.
Assuming that you have your boundary defined, you can use a ray casting algorithm to determine whether or not the polygon is inside the domain.
To do this:
C_i = (x_i,y_i)
.L = [C_i,(+inf,y_i)]
: that is, a line that spans east past the end of your domain.s_i
in boundary S
, check for intersections with L
. If yes, add +1 to an internal counter intersection_count
; else, add nothing. After the count of all intersections between L
and s_i for i=1..N
are calculated:
if intersection_count % 2 == 0:
return True # triangle outside convex hull
else:
return False # triangle inside convex hull
If your boundary is not explicitly defined, I find it helpful to 'map' the shape onto an boolean array and use a neighbor tracing algorithm to define it. Note that this approach assumes a solid domain and you will need to use a more complex algorithm for domains with 'holes' in them.