The CGA FAQ describes an algorithm to test if a point lies within a polygon. Roughly speaking, you start from the point and travel north. If you cross an odd number of sides, it means that you were within the polygon when you started and vice versa.

The details of the solution can be found in the CGA FAQ linked above. A C++ implementation can be found here: http://code.google.com/p/curve-project/source/browse/trunk/lab/cgafaq/cgafaq.h The function `cgafaq::point_in_polygon`

takes a point and a polygon and returns whether or not the point lies inside the polygon. This is a direct translation of the code from the FAQ.

**Disclaimer:** This post and the code provided are not endorsed by any of the contributors to the CGA FAQ.