Listing 3. The Guts of the inpoly() Routine

if ((xnew < xt) == (xt <= xold)
    /* straddle test */
 && ((long)yt-(long)y1)*(long)(x2-x1)
    /* north */
  < ((long)y2-(long)y1)*(long)(xt-x1)) {
    /* test  */
     inside=!inside;
}