/* PNPOLY - Test if a point is contained in a 2D polygon. */ #include /* The code below is from Wm. Randolph Franklin with some minor modifications for speed and style. comp.graphics.algorithms FAQ References: [Gems IV] pp. 24-46 [O'Rourke] pp. 233-238 [Glassner:RayTracing] */ static int pnpoly(int npol, double *xp, double *yp, double x, double y) { int i, j, c = 0; for (i = 0, j = npol-1; i < npol; j = i++) { if ((((yp[i]<=y) && (y