I have a collection of 2D points S
and I need to test if an input point q
is inside or outside the convex hull of S
.
Since it\
An alternative solution using angles:
Pick some point C inside the convex hull using some heuristic of your choice.
Pick some line L passing through C, for instance the line parallel to the OX axis.
For every point P on the convex hull, calculate the angle between the line CP and L and use it to sort the convex hull points.
Now if you want to know if some given point T is inside the convex hull, calculate the angle between the lines CT and L and using binary search look for the points in the convex hull which are just after and before it (A and B respectively).
Now you only have to check it T is at the same side of the line AB than C (inside) or not (outside).