見つかった解決策:
int wn_PnPoly2(Point P, vector<Point> V, int n)
{
int wn = 0; // the winding number counter
// loop through all edges of the polygon
for (int i = 0; i<n; i++) { // edge from V[i] to V[i+1]
if (V[i].Y <= P.Y) { // start y <= P.y
if (V[i + 1].Y > P.Y) // an upward crossing
{
int l = isLeft(V[i], V[i + 1], P);
if (l > 0) // P left of edge
++wn; // have a valid up intersect
else if (l == 0) // boundary
return 0;
}
}
else { // start y > P.y (no test needed)
if (V[i + 1].Y <= P.Y) // a downward crossing
{
int l = isLeft(V[i], V[i + 1], P);
if (l < 0) // P right of edge
--wn; // have a valid down intersect
else if (l == 0)
return 0;
}
}
}
return wn;
}