Make MathUtil::interpolate a bit more robust in the presence of possible
rounding errors.
This commit is contained in:
parent
fbd80f480d
commit
0910317bf6
@ -331,13 +331,13 @@ public class MathUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int length = domain.size();
|
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;
|
return Double.NaN;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Look for the index of the right end point.
|
// Look for the index of the right end point.
|
||||||
int right = 1;
|
int right = 1;
|
||||||
while (t > domain.get(right)) {
|
while (t > domain.get(right) + EPSILON) {
|
||||||
right++;
|
right++;
|
||||||
}
|
}
|
||||||
int left = right - 1;
|
int left = right - 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user