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; }