diff --git a/lib/vdc/vizutil.cpp b/lib/vdc/vizutil.cpp index 07089437c1..2f2deea870 100644 --- a/lib/vdc/vizutil.cpp +++ b/lib/vdc/vizutil.cpp @@ -1,5 +1,6 @@ #include #include +#include #include "vapor/VAssert.h" #include @@ -186,6 +187,11 @@ bool VAPoR::BarycentricCoordsTri(const double verts[], const double pt[], double lambda[2] = (d00 * d21 - d01 * d20) / denom; lambda[0] = 1.0f - lambda[1] - lambda[2]; + const double epsilon = std::numeric_limits::epsilon(); + if ((lambda[0] < 0.0) && ((lambda[0] + epsilon) >= 0.0)) lambda[0] = 0.0; + if ((lambda[1] < 0.0) && ((lambda[1] + epsilon) >= 0.0)) lambda[1] = 0.0; + if ((lambda[2] < 0.0) && ((lambda[2] + epsilon) >= 0.0)) lambda[2] = 0.0; + return (lambda[0] >= 0.0 && lambda[1] >= 0.0 && lambda[2] >= 0.0); }