From 482ca1036382c715bc041567bbcae58a4cdd37ad Mon Sep 17 00:00:00 2001 From: Gabriel Ozouf Date: Wed, 14 Oct 2020 10:24:47 +0200 Subject: [PATCH] [poincare/zoom] Improve null range When displaying f(x) = undef, the range now defaults to an orthonormal range, centered on the origin, with axis unit 1. Change-Id: Ie3515be0572af4849b8ebd113449f4444755b34f --- poincare/src/zoom.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/poincare/src/zoom.cpp b/poincare/src/zoom.cpp index 0744ed605..83430c660 100644 --- a/poincare/src/zoom.cpp +++ b/poincare/src/zoom.cpp @@ -184,11 +184,16 @@ void Zoom::RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float * its average order of magnitude. Then, bound is the value for the next * order of magnitude and is used to cut the Y range. */ - float bound = (pop > 0) ? std::exp(sum / pop + 1.f) : FLT_MAX; - sampleYMin = std::max(sampleYMin, - bound); - sampleYMax = std::min(sampleYMax, bound); - *yMin = sampleYMin; - *yMax = sampleYMax; + if (pop == 0) { + *yMin = 0; + *yMax = 0; + } else { + float bound = std::exp(sum / pop + 1.f); + sampleYMin = std::max(sampleYMin, - bound); + sampleYMax = std::min(sampleYMax, bound); + *yMin = sampleYMin; + *yMax = sampleYMax; + } if (*yMin == *yMax) { RangeFromSingleValue(*yMin, yMin, yMax); }