Make MathUtil::interpolate a bit more robust in the presence of possible

rounding errors.
This commit is contained in:
JoePfeiffer 2022-05-13 11:52:22 -06:00
parent fbd80f480d
commit 0910317bf6

View File

@ -331,13 +331,13 @@ public class MathUtil {
}
int length = domain.size();
if (length <= 1 || t < domain.get(0) || t > domain.get(length - 1)) {
if (length <= 1 || t < domain.get(0) || t > domain.get(length - 1) + EPSILON) {
return Double.NaN;
}
// Look for the index of the right end point.
int right = 1;
while (t > domain.get(right)) {
while (t > domain.get(right) + EPSILON) {
right++;
}
int left = right - 1;