清单 3. inpoly() 程序的内部原理

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;
}
© . All rights reserved.