mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
[poincare/zoom] Method SetToRatio
Added a method to Zoom to set a range to a specific ratio. This method is used by InteractiveCurveViewRange::normalize. Change-Id: Id3029439294ece02ea19fb6c6de90b9edc85d771
This commit is contained in:
committed by
Émilie Feral
parent
c4aad1641e
commit
08c96c5107
@@ -15,6 +15,10 @@ public:
|
||||
static void InterestingRangesForDisplay(ValueAtAbscissa evaluation, float * xMin, float * xMax, float * yMin, float * yMax, float tMin, float tMax, Context * context, const void * auxiliary);
|
||||
static void RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float xMax, float * yMin, float * yMax, Context * context, const void * auxiliary, bool boundByMagnitude = false);
|
||||
|
||||
/* 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);
|
||||
|
||||
private:
|
||||
static constexpr int k_peakNumberOfPointsOfInterest = 3;
|
||||
static constexpr int k_sampleSize = Ion::Display::Width / 4;
|
||||
|
||||
@@ -199,6 +199,29 @@ void Zoom::RefinedYRangeForDisplay(ValueAtAbscissa evaluation, float xMin, float
|
||||
}
|
||||
}
|
||||
|
||||
void Zoom::SetToRatio(float yxRatio, float * xMin, float * xMax, float * yMin, float * yMax, bool shrink) {
|
||||
float currentRatio = (*yMax - *yMin) / (*xMax - *xMin);
|
||||
|
||||
float * tMin;
|
||||
float * tMax;
|
||||
float newRange;
|
||||
if ((currentRatio < yxRatio) == shrink) {
|
||||
/* Y axis too small and shrink, or Y axis too large and do not shrink
|
||||
* --> we change the X axis*/
|
||||
tMin = xMin;
|
||||
tMax = xMax;
|
||||
newRange = (*yMax - *yMin) / yxRatio;
|
||||
} else {
|
||||
tMin = yMin;
|
||||
tMax = yMax;
|
||||
newRange = (*xMax - *xMin) * yxRatio;
|
||||
}
|
||||
|
||||
float center = (*tMax + *tMin) / 2.f;
|
||||
*tMax = center + newRange / 2.f;
|
||||
*tMin = center - newRange / 2.f;
|
||||
}
|
||||
|
||||
bool Zoom::IsConvexAroundExtremum(ValueAtAbscissa evaluation, float x1, float x2, float x3, float y1, float y2, float y3, Context * context, const void * auxiliary, int iterations) {
|
||||
if (iterations <= 0) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user