[interactive_curve_view_range] Force equal axes

Added a tolerance when checking orthonormality, so that ranges that are
nearly orthonormal will be made orthonormal.

Change-Id: Ie3bf076086561e3ff6374e7daa9dd1a884c52d5a
This commit is contained in:
Gabriel Ozouf
2020-10-14 11:15:35 +02:00
committed by Émilie Feral
parent 482ca10363
commit 8ce9f363ad
2 changed files with 6 additions and 5 deletions

View File

@@ -115,7 +115,7 @@ void InteractiveCurveViewRange::setDefault() {
// Compute the interesting range
m_delegate->interestingRanges(this);
bool revertToNormalized = isOrthonormal();
bool revertToNormalized = isOrthonormal(k_orthonormalTolerance);
// Add margins
float xRange = xMax() - xMin();
@@ -198,8 +198,8 @@ void InteractiveCurveViewRange::checkForNormalizedRange() {
}
bool InteractiveCurveViewRange::isOrthonormal(float tolerance) const {
float pixelHeight = std::round(Ion::Display::Height * (NormalizedYHalfRange(100.f) / Ion::Display::HeightInTenthOfMillimeter));
float pixelWidth = std::round(Ion::Display::Width * (NormalizedXHalfRange(100.f) / Ion::Display::WidthInTenthOfMillimeter));
return std::fabs(std::round(pixelHeight * (xMax() - xMin())) - std::round(pixelWidth * (yMax() - yMin()))) <= tolerance;
float ratio = (yMax() - yMin()) / (xMax() - xMin());
float ratioDifference = std::fabs(std::log(ratio / NormalYXRatio()));
return ratioDifference <= tolerance;
}
}