[poincare/zoom] Method FullRange

Change-Id: Ibfaa0b694afecab312199b20b102a57901f34ae7
This commit is contained in:
Gabriel Ozouf
2020-10-12 12:56:34 +02:00
committed by Émilie Feral
parent 09c061e871
commit 81e425eb04
2 changed files with 20 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ public:
static bool InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary);
static void RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float xMax, float * yMin, float * yMax, Context * context, const void * auxiliary, bool boundByMagnitude = false);
static void RangeWithRatioForDisplay(ValueAtAbscissa evaluation, float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary);
static void FullRange(ValueAtAbscissa evaluation, float tMin, float tMax, float tStep, float * fMin, float * fMax, Context * context, const void * auxiliary);
/* If shrink is false, the range will be set to ratio by increasing the size
* of the smallest axis. If it is true, the longest axis will be reduced.*/

View File

@@ -262,6 +262,25 @@ void Zoom::RangeWithRatioForDisplay(ValueAtAbscissa evaluation, float yxRatio, f
SetToRatio(yxRatio, xMin, xMax, yMin, yMax, true);
}
void Zoom::FullRange(ValueAtAbscissa evaluation, float tMin, float tMax, float tStep, float * fMin, float * fMax, Context * context, const void * auxiliary) {
float t = tMin;
*fMin = FLT_MAX;
*fMax = -FLT_MAX;
while (t <= tMax) {
float value = evaluation(t, context, auxiliary);
if (value < *fMin) {
*fMin = value;
}
if (value > *fMax) {
*fMax = value;
}
t += tStep;
}
if (*fMin == *fMax) {
RangeFromSingleValue(*fMin, fMin, fMax);
}
}
void Zoom::RangeFromSingleValue(float value, float * boundMin, float * boundMax) {
constexpr float margin = 0.2f;
float delta = margin * std::fabs(value);