
Basically, there are two algorithms determining whether a point is inside,
outside or on the polygon. The first one is Ray (or half line) method. In
this method, you can draw any ray, if the number of the intersection point
of the ray and the polygon is even, then it is outside. If the number is odd,
then it is inside. Of cause, you have to deal with the special cases which
may make you headache.

The second method is PI algorithm. Draw the lines between the point and
all the vertices on the polygon. Calculate and sum the angles of the
successive lines. If the result is 2*PI, then it is inside. If PI, then
it is on the polygon. Otherwise it is outside.

My experience tells the second method is relible.

Hope this helps.