From b4da9ecbece9a528560e891ca461257ff321829f Mon Sep 17 00:00:00 2001 From: johncbaur <46469358+johncbaur@users.noreply.github.com> Date: Fri, 30 Aug 2024 10:04:40 -0500 Subject: [PATCH] VIX-3585 Fixing interpolation bug when consecutive points have the same Y value VIX-3585 Fixing interpolation bug when consecutive points have the same Y value --- src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs b/src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs index 70ca85358..569338f9a 100644 --- a/src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs +++ b/src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs @@ -649,6 +649,13 @@ public double InterpolateX(double xTarget) throw new Exception("Error: Infinite loop in interpolation"); } + // If the point Y values are identical there is no need to interpolate + //.This avoids returning NaN + if (this[hi].Y == this[lo].Y) + { + return this[hi].Y; + } + return (xTarget - this[lo].X)/(this[hi].X - this[lo].X)* (this[hi].Y - this[lo].Y) + this[lo].Y; }