[apps/calculation] additional_outputs; fix range of ComplexGraphView

This commit is contained in:
Émilie Feral
2020-01-08 18:13:51 +01:00
committed by Léa Saviot
parent 61d0161e74
commit 56485a9733

View File

@@ -8,28 +8,34 @@ ComplexModel::ComplexModel(std::complex<float> c) :
{
}
float rangeBound(float value, float direction) {
float rangeBound(float value, float direction, bool horizontal) {
if (std::isnan(value) || std::isinf(value) || value == 0.0f) {
return direction;
}
float factor = direction*value >= 0.0f ? 1.2f : -0.3f;
float minFactor = -0.5f;
float maxFactor = 1.2f;
if (horizontal) {
minFactor = -1.0f;
maxFactor = 2.0f;
}
float factor = direction*value >= 0.0f ? maxFactor : minFactor;
return factor*value;
}
float ComplexModel::xMin() const {
return rangeBound(real(), -1.0f);
return rangeBound(real(), -1.0f, true);
}
float ComplexModel::xMax() const {
return rangeBound(real(), 1.0f);
return rangeBound(real(), 1.0f, true);
}
float ComplexModel::yMin() const {
return rangeBound(imag(), -1.0f);
return rangeBound(imag(), -1.0f, false);
}
float ComplexModel::yMax() const {
return rangeBound(imag(), 1.0f);
return rangeBound(imag(), 1.0f, false);
}
}