diff --git a/math/mathcore/inc/TMath.h b/math/mathcore/inc/TMath.h index 0342a58853a94..3f1a0a7e0c138 100644 --- a/math/mathcore/inc/TMath.h +++ b/math/mathcore/inc/TMath.h @@ -1330,8 +1330,22 @@ template Bool_t TMath::IsInside(T xp, T yp, Int_t np, T *x, T *y) for (i=0; i=yp) || (y[j]=yp)) { - if (x[i]+(yp-y[i])/(y[j]-y[i])*(x[j]-x[i])::is_integer) { + const Long64_t dx = static_cast(x[j]) - x[i]; + const Long64_t dy = static_cast(y[j]) - y[i]; + const Long64_t py = static_cast(yp) - y[i]; + const Long64_t px = static_cast(xp) - x[i]; + + const Long64_t lhs = py * dx; + const Long64_t rhs = px * dy; + + if ((dy > 0 && lhs < rhs) || (dy < 0 && lhs > rhs)) { + oddNodes = !oddNodes; + } + } else { + if (x[i]+(yp-y[i])/(y[j]-y[i])*(x[j]-x[i])(xp), static_cast(yp), n, xd, yd)); + } + } +} + template void testPlane() { @@ -299,6 +316,7 @@ int main() testPoints(1.3, 0.5); testPoints(-0.2, 1.7); testPoints(1, 1); + testIsInsideInt(); cout << "\nPLane functions tests: " << endl;