/****************************************************************************/
// return 1 if selected point is inside polygon, 0 otherwise
// npol=no of points, x,y =coordinates of selected point, xp,yp = polygon coordi
nates

 int pnpoly(int npol, float *xp, float *yp, float x, float y)
    {
      int i, j, c = 0;
      for (i = 0, j = npol-1; i < npol; j = i++) {
        if ((((yp[i]<=y) && (y<yp[j])) ||
             ((yp[j]<=y) && (y<yp[i]))) &&
            (x < (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
        {
          c = !c;
        }
      }
      return c;
    }




