[shared] FunctionGraphController: fix computeYRange for 1/x

This commit is contained in:
Émilie Feral
2018-06-13 16:40:12 +02:00
committed by LeaNumworks
parent b4fce2d6d4
commit a1d6b90705

View File

@@ -79,8 +79,11 @@ InteractiveCurveViewRangeDelegate::Range FunctionGraphController::computeYRange(
for (int i=0; i<functionStore()->numberOfActiveFunctions(); i++) {
Function * f = functionStore()->activeFunctionAtIndex(i);
float y = 0.0f;
for (int j = 0; j <= curveView()->resolution(); j++) {
float x = xMin+(xMax-xMin)*j/curveView()->resolution();
float res = curveView()->resolution();
/* Scan x-range from the middle to the extrema in order to get balanced
* y-range for even functions (y = 1/x). */
for (int j = -res/2; j <= res/2; j++) {
float x = (xMin+xMax)/2.0+(xMax-xMin)*j/res;
y = f->evaluateAtAbscissa(x, myApp->localContext());
if (!std::isnan(y) && !std::isinf(y)) {
min = min < y ? min : y;