[apps] Shared: when adjusting yAuto and scanning y values, avoid

rounding errors (avoid weird range for y = 1/x)
This commit is contained in:
Émilie Feral
2018-02-14 12:01:51 +01:00
committed by EmilieNumworks
parent 6de71ae145
commit e4fbfe3a77

View File

@@ -70,7 +70,6 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
float max = -FLT_MAX;
float xMin = interactiveCurveViewRange->xMin();
float xMax = interactiveCurveViewRange->xMax();
float step = (xMax - xMin)/curveView()->resolution();
if (functionStore()->numberOfActiveFunctions() <= 0) {
InteractiveCurveViewRangeDelegate::Range range;
range.min = xMin;
@@ -80,8 +79,8 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
for (int i=0; i<functionStore()->numberOfActiveFunctions(); i++) {
Function * f = functionStore()->activeFunctionAtIndex(i);
float y = 0.0f;
for (int i = 0; i <= curveView()->resolution(); i++) {
float x = xMin + i*step;
for (int j = 0; j <= curveView()->resolution(); j++) {
float x = xMin+(xMax-xMin)*j/curveView()->resolution();
y = f->evaluateAtAbscissa(x, myApp->localContext());
if (!std::isnan(y) && !std::isinf(y)) {
min = min < y ? min : y;