[poincare/zoom] RefinedYRangeForDisplay signature

This commit is contained in:
Gabriel Ozouf
2020-12-09 12:16:56 +01:00
committed by EmilieNumworks
parent 3cdb076c2c
commit 625a89e610
4 changed files with 8 additions and 8 deletions

View File

@@ -287,7 +287,7 @@ void ContinuousFunction::rangeForDisplay(float * xMin, float * xMax, float * yMi
if (fullyComputed) { if (fullyComputed) {
/* The function has points of interest. */ /* The function has points of interest. */
Zoom::RefinedYRangeForDisplay(evaluation, *xMin, *xMax, yMin, yMax, context, this); Zoom::RefinedYRangeForDisplay(evaluation, xMin, xMax, yMin, yMax, context, this);
return; return;
} }
@@ -301,7 +301,7 @@ void ContinuousFunction::rangeForDisplay(float * xMin, float * xMax, float * yMi
* Try a basic range. */ * Try a basic range. */
*xMin = - Zoom::k_defaultHalfRange; *xMin = - Zoom::k_defaultHalfRange;
*xMax = Zoom::k_defaultHalfRange; *xMax = Zoom::k_defaultHalfRange;
Zoom::RefinedYRangeForDisplay(evaluation, *xMin, *xMax, yMin, yMax, context, this); Zoom::RefinedYRangeForDisplay(evaluation, xMin, xMax, yMin, yMax, context, this);
if (std::isfinite(*xMin) && std::isfinite(*xMax) && std::isfinite(*yMin) && std::isfinite(*yMax)) { if (std::isfinite(*xMin) && std::isfinite(*xMax) && std::isfinite(*yMin) && std::isfinite(*yMax)) {
return; return;
} }

View File

@@ -22,7 +22,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 bool InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary);
/* Find the best Y range to display the function on [xMin, xMax], but crop /* Find the best Y range to display the function on [xMin, xMax], but crop
* the values that are outside of the function's order of magnitude. */ * the values that are outside of the function's order of magnitude. */
static void RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float xMax, float * yMin, float * yMax, Context * context, const void * auxiliary, int sampleSize = k_sampleSize); static void RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary);
/* Find the best window to display functions, with a specified ratio /* Find the best window to display functions, with a specified ratio
* between X and Y. Usually used to find the most fitting orthonormal range. */ * between X and Y. Usually used to find the most fitting orthonormal range. */
static void RangeWithRatioForDisplay(ValueAtAbscissa evaluation, float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary); static void RangeWithRatioForDisplay(ValueAtAbscissa evaluation, float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary);

View File

@@ -195,20 +195,20 @@ bool Zoom::InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin,
return true; return true;
} }
void Zoom::RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float xMax, float * yMin, float * yMax, Context * context, const void * auxiliary, int sampleSize) { void Zoom::RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, Context * context, const void * auxiliary) {
/* This methods computes the Y range that will be displayed for cartesian /* This methods computes the Y range that will be displayed for cartesian
* functions and sequences, given an X range (xMin, xMax) and bounds yMin and * functions and sequences, given an X range (xMin, xMax) and bounds yMin and
* yMax that must be inside the Y range.*/ * yMax that must be inside the Y range.*/
assert(yMin && yMax); assert(yMin && yMax);
float sampleYMin = FLT_MAX, sampleYMax = -FLT_MAX; float sampleYMin = FLT_MAX, sampleYMax = -FLT_MAX;
const float step = (xMax - xMin) / (sampleSize - 1); const float step = (*xMax - *xMin) / (k_sampleSize - 1);
float x, y; float x, y;
float sum = 0.f; float sum = 0.f;
int pop = 0; int pop = 0;
for (int i = 1; i < sampleSize - 1; i++) { for (int i = 1; i < k_sampleSize - 1; i++) {
x = xMin + i * step; x = *xMin + i * step;
y = evaluation(x, context, auxiliary); y = evaluation(x, context, auxiliary);
if (!std::isfinite(y)) { if (!std::isfinite(y)) {
continue; continue;

View File

@@ -98,7 +98,7 @@ void assert_refined_range_is(const char * definition, float xMin, float xMax, fl
Shared::GlobalContext globalContext; Shared::GlobalContext globalContext;
Expression e = parse_expression(definition, &globalContext, false); Expression e = parse_expression(definition, &globalContext, false);
ParametersPack aux(e, symbol, angleUnit); ParametersPack aux(e, symbol, angleUnit);
Zoom::RefinedYRangeForDisplay(evaluate_expression, xMin, xMax, &yMin, &yMax, &globalContext, &aux); Zoom::RefinedYRangeForDisplay(evaluate_expression, &xMin, &xMax, &yMin, &yMax, &globalContext, &aux);
quiz_assert_print_if_failure(range1D_matches(yMin, yMax, targetYMin, targetYMax), definition); quiz_assert_print_if_failure(range1D_matches(yMin, yMax, targetYMin, targetYMax), definition);
} }