Here is a C function to determine if a point lies within a polygon:
Code:
c=0;
                for (i = 0, j = nbpol-1; i < nbpol; j = i++) {
                        if ((((tY[i]<=Y) && (Y<tY[j])) || ((tY[j]<=Y) && (Y<tY[i]))) &&
                        (X < (tX[j] - tX[i]) * (Y - tY[i]) / (tY[j] - tY[i]) + tX[i]))
                         c = !c;
                }
where tX and tY contain the points of the polygon, nbpol is the number of points, X and Y are the point.

if c is true the point is within.

Rob