title: Check point within polygon
body: <pre><code>int pnpoly(int npol, float *xp, float *yp, float x, float y)
  {
     int i, j, c = 0;
     for (i = 0, j = npol-1; i &lt; npol; j = i++) {
       if ((((yp[i] &lt;= y) &amp;&amp; (y &lt; yp[j])) ||
          ((yp[j] &lt;= y) &amp;&amp; (y &lt; yp[i]))) &amp;&amp;
          (x &lt; (xp[j] - xp[i]) * (y - yp[i]) / (yp[j] - yp[i]) + xp[i]))
         c = !c;
     }
     return c;
  }
  </code></pre>
  
  <p>This function checks if a point is within a polygon. How do I deal with a polygon coordinate that is negative? For example,</p>
  
  <pre><code>float x[3] = { 0.16, 1.2, -10 };
  float y[3] = { 1.8, 10, -5.5 };
  </code></pre>
  
  <p>I tried checking a valid point within the polygon and it returns 0.</p>