Skip to content

Commit

Permalink
Fixed #3018 - Artifacts in slice renderer kalundquist data (#3019)
Browse files Browse the repository at this point in the history
Floating point round off error in VAPoR::BarycentricCoordsTri()
  • Loading branch information
clyne authored Feb 14, 2022
1 parent 74a8fb0 commit 4169163
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/vdc/vizutil.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include <cmath>
#include <iostream>
#include <limits>
#include "vapor/VAssert.h"
#include <vapor/vizutil.h>

Expand Down Expand Up @@ -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<double>::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);
}

Expand Down

0 comments on commit 4169163

Please sign in to comment.