To determine whether a point is in a triangle, draw a ray out from the point. If it crosses the boundary of the triangle once, then the point is inside the triangle. If the ray crosses zero or two times, the point is outside. In this example you can drag the point and the Demonstration determines (and counts) the intersection points. This technique can be generalized to an arbitrary nonconvex polygon.