mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/zoom] Method CombineRanges
The logic behind combining several ranges will be handled by the Zoom class directly. Change-Id: I4de3f020d94b9bc1a21953b0c416158c65beb606
This commit is contained in:
committed by
Émilie Feral
parent
81e425eb04
commit
8572f4953c
@@ -23,6 +23,8 @@ public:
|
||||
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);
|
||||
|
||||
static void CombineRanges(int length, const float * mins, const float * maxs, float * minRes, float * maxRes);
|
||||
|
||||
/* 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.*/
|
||||
static void SetToRatio(float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, bool shrink = false);
|
||||
|
||||
@@ -204,6 +204,25 @@ void Zoom::RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float
|
||||
}
|
||||
}
|
||||
|
||||
void Zoom::CombineRanges(int length, const float * mins, const float * maxs, float * minRes, float * maxRes) {
|
||||
ValueAtAbscissa evaluation = [](float x, Context * context, const void * auxiliary) {
|
||||
int index = std::round(x);
|
||||
return static_cast<const float *>(auxiliary)[index];
|
||||
};
|
||||
FullRange(evaluation, 0, length - 1, 1, minRes, maxRes, nullptr, mins);
|
||||
float min, max;
|
||||
FullRange(evaluation, 0, length - 1, 1, &min, &max, nullptr, maxs);
|
||||
if (min < *minRes) {
|
||||
*minRes = min;
|
||||
}
|
||||
if (max > *maxRes) {
|
||||
*maxRes = max;
|
||||
}
|
||||
if (*minRes == *maxRes) {
|
||||
RangeFromSingleValue(*minRes, minRes, maxRes);
|
||||
}
|
||||
}
|
||||
|
||||
void Zoom::SetToRatio(float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, bool shrink) {
|
||||
float currentRatio = (*yMax - *yMin) / (*xMax - *xMin);
|
||||
|
||||
@@ -276,9 +295,6 @@ void Zoom::FullRange(ValueAtAbscissa evaluation, float tMin, float tMax, float t
|
||||
}
|
||||
t += tStep;
|
||||
}
|
||||
if (*fMin == *fMax) {
|
||||
RangeFromSingleValue(*fMin, fMin, fMax);
|
||||
}
|
||||
}
|
||||
|
||||
void Zoom::RangeFromSingleValue(float value, float * boundMin, float * boundMax) {
|
||||
|
||||
Reference in New Issue
Block a user