[apps/graph] Fix computeYRange for polar/cartesian functions

Was very slow, compute only 1000 values to evaluate the yRange
This commit is contained in:
Léa Saviot
2019-09-03 13:57:06 +02:00
parent a4099c4c3e
commit c3ee6a71e7
4 changed files with 14 additions and 5 deletions

View File

@@ -75,12 +75,16 @@ void GraphController::interestingRanges(float * xm, float * xM, float * ym, floa
double tMax = f->tMax();
assert(!std::isnan(tMin));
assert(!std::isnan(tMax));
interestingFunctionRange(f, tMin, tMax, (tMax - tMin)/30, &resultxMin, &resultxMax, &resultyMin, &resultyMax);
assert(!std::isnan(f->rangeStep()));
interestingFunctionRange(f, tMin, tMax, f->rangeStep(), &resultxMin, &resultxMax, &resultyMin, &resultyMax);
}
} else {
resultxMin = xMin;
resultxMax = xMax;
}
/* In practice, a step smaller than a pixel's width is needed for sampling
* the values of a function. Otherwise some relevant extremal values may be
* missed. */
const float step = const_cast<GraphController *>(this)->curveView()->pixelWidth() / 2;
for (int i = 0; i < functionStore()->numberOfActiveFunctions(); i++) {
ExpiringPointer<CartesianFunction> f = functionStore()->modelForRecord(functionStore()->activeRecordAtIndex(i));