From 0910317bf62c1b8ff7a1ea62fe2c1edfa4a8df12 Mon Sep 17 00:00:00 2001 From: JoePfeiffer Date: Fri, 13 May 2022 11:52:22 -0600 Subject: [PATCH] Make MathUtil::interpolate a bit more robust in the presence of possible rounding errors. --- core/src/net/sf/openrocket/util/MathUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/net/sf/openrocket/util/MathUtil.java b/core/src/net/sf/openrocket/util/MathUtil.java index e1ae86c12..e948ee8d5 100644 --- a/core/src/net/sf/openrocket/util/MathUtil.java +++ b/core/src/net/sf/openrocket/util/MathUtil.java @@ -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;