From 2a37fa44473dfbd0413db6213393f8b71b727c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 16 Jan 2020 17:53:37 +0100 Subject: [PATCH] [apps/calculation] ComplexListController: change the way the Complex model parameters are computed. Sometimes, approximation without simplification doesn't not give the same results as approximation after simplification. As we decided to display the additional results from an approximation without simplifcation (done in Expression::hasDefinedComplexApproximation), we compute the model parameters the same way (to ensure that both parameters are defined) --- .../additional_outputs/complex_list_controller.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/calculation/additional_outputs/complex_list_controller.cpp b/apps/calculation/additional_outputs/complex_list_controller.cpp index 9318e89a2..9bfd3e960 100644 --- a/apps/calculation/additional_outputs/complex_list_controller.cpp +++ b/apps/calculation/additional_outputs/complex_list_controller.cpp @@ -1,6 +1,9 @@ #include "complex_list_controller.h" #include "../app.h" #include "../../shared/poincare_helpers.h" +#include +#include +#include "complex_list_controller.h" using namespace Poincare; using namespace Shared; @@ -29,8 +32,9 @@ void ComplexListController::setExpression(Poincare::Expression e) { m_calculationStore.push("abs(z)", context); // Set Complex illustration - float a = Shared::PoincareHelpers::ApproximateToScalar(m_calculationStore.calculationAtIndex(2)->approximateOutput(context), context); - float b = Shared::PoincareHelpers::ApproximateToScalar(m_calculationStore.calculationAtIndex(3)->approximateOutput(context), context); + // Compute a and b as in Expression::hasDefinedComplexApproximation to ensure the same defined result + float a = Shared::PoincareHelpers::ApproximateToScalar(RealPart::Builder(e.clone()), context); + float b = Shared::PoincareHelpers::ApproximateToScalar(ImaginaryPart::Builder(e.clone()), context); m_model.setComplex(std::complex(a,b)); // Reset complex format as before