Skip to content

Commit

Permalink
VIX-3585 Fixing interpolation bug when consecutive points have the sa…
Browse files Browse the repository at this point in the history
…me Y value

VIX-3585 Fixing interpolation bug when consecutive points have the same Y value
  • Loading branch information
johncbaur committed Aug 30, 2024
1 parent 8991961 commit b4da9ec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Vixen.Modules/App/Curves/ZedGraph/PointPairList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit b4da9ec

Please sign in to comment.