You can check if the shape is a convex hull, bypassing all the edges, and checking the next edge always moves in one direction (left / right). This is a fast and cheap algorithm. There is an implementation of this here: en.wikipedia.org/wiki/Graham_scan
If you don’t have a convex hull, follow the batch packing algorithm to get a convex hull that spans all your points (again pretty quickly). en.wikipedia.org/wiki/Gift_wrapping_algorithm
Now find the points that are on your shape, but not on the convex hull. For each run of these points, create a new shape from these points (plus two sides on the convex hull).
Recursion is now your friend: follow the same process on each of the subforms you just made.
I used these methods to verify that the point is contained inside an arbitrary shape: that is, the point should be inside the convex hull (easy to check), but not any of the subforms or their subforms, or their subforms ....
Adrian taylor
source share