From 82c4fe2190819dcdf19e793f496c90374357c70c Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Mon, 19 Oct 2020 17:33:57 +0200 Subject: [PATCH] [poincare/zoom] Limit explosion detection Do not take strong variations into account if they would erase more interesting variations. Change-Id: I6299a64bed449a611f90eda4234af10a183958d1 --- poincare/src/zoom.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/poincare/src/zoom.cpp b/poincare/src/zoom.cpp index a649ed368..b9683b6f2 100644 --- a/poincare/src/zoom.cpp +++ b/poincare/src/zoom.cpp @@ -152,8 +152,12 @@ bool Zoom::InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, *yMax = NAN; return false; } else { - resultX[0] = std::min(resultX[0], explosion[0]); - resultX[1] = std::max(resultX[1], explosion[1]); + float xMinWithExplosion = std::min(resultX[0], explosion[0]); + float xMaxWithExplosion = std::max(resultX[1], explosion[1]); + if (xMaxWithExplosion - xMinWithExplosion < k_maxRatioBetweenPointsOfInterest * (resultX[1] - resultX[0])) { + resultX[0] = xMinWithExplosion; + resultX[1] = xMaxWithExplosion; + } /* Add breathing room around points of interest. */ float xRange = resultX[1] - resultX[0]; resultX[0] -= k_breathingRoom * xRange;