Is there a predefined function to check whether a point is inside the (possibly nonconvex) polygon? If there isn't, how can I define it?
1º) define isinsidetriangle[A,B,C,H] (could be using baricentre coords and solving the system or another processing)
2º) H is inside poly[A,B,C,D,E,F,G] when the number isinsidetriangle[A,B,C,H]+isinsidetriangle[A,C,D,H]+isinsidetriangle[A,D,E,H]+isinsidetriangle[A,E,F,H] + isinsidetriangle[A,F,G,H] is a odd number
i hope to be useful
I don't know barycentric coords, so I don't really have an idea how to do this.
But I did try to implement a PointInsideTriangle using the winding number method: the sum of angles ADB, BDC and CDB is 0 iff D is outside triangle ABC. This worked to some extent: if you changed the triangle orientation by moving one of the vertex points, the result came out wrong.
don't use baricentric coords
use the idea my last reply for point inside triangle
You're right, this works. In fact, I even tried something like this in my very first try but I must have mistyped something because I got wrong result in some cases.
However, it's not possible to define this as a function in a single line as above, is it? I do "t=If[poly1==poly2+poly3+poly4,1,0]" and then construct a macro...
Comments have been locked on this page!