From dd6a729f65b1b9fcba0770e24fb117a0cc48f5c6 Mon Sep 17 00:00:00 2001 From: Neven Sajko Date: Tue, 25 Feb 2020 18:49:58 +0000 Subject: [PATCH] Better usage of some floating point constants --- apps/calculation/additional_outputs/complex_graph_cell.cpp | 4 ++-- python/port/mod/turtle/turtle.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/calculation/additional_outputs/complex_graph_cell.cpp b/apps/calculation/additional_outputs/complex_graph_cell.cpp index 4436d784d..bc8a687b3 100644 --- a/apps/calculation/additional_outputs/complex_graph_cell.cpp +++ b/apps/calculation/additional_outputs/complex_graph_cell.cpp @@ -39,7 +39,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { * and the line of equation (real*t,imag*t). * (a*cos(t), b*sin(t)) = (real*t,imag*t) --> tan(t) = sign(a)*sign(b) (± π) * --> t = π/4 [π/2] according to sign(a) and sign(b). */ - float th = real < 0.0f ? 3.0f*(float)M_PI/4.0f : (float)M_PI/4.0f; + float th = real < 0.0f ? (float)(3.0*M_PI_4) : (float)M_PI_4; th = imag < 0.0f ? -th : th; // Compute ellipsis parameters a and b float factor = 5.0f; @@ -48,7 +48,7 @@ void ComplexGraphView::drawRect(KDContext * ctx, KDRect rect) const { // Avoid flat ellipsis for edge cases (for real = 0, the case imag = 0 is excluded) if (real == 0.0f) { a = 1.0f/factor; - th = imag < 0.0f ? -(float)M_PI/2.0f : (float)M_PI/2.0f; + th = imag < 0.0f ? (float)-M_PI_2 : (float)M_PI_2; } std::complex parameters(a,b); drawCurve(ctx, rect, 0.0f, 1.0f, 0.01f, diff --git a/python/port/mod/turtle/turtle.cpp b/python/port/mod/turtle/turtle.cpp index 58b51c4c2..d580e7007 100644 --- a/python/port/mod/turtle/turtle.cpp +++ b/python/port/mod/turtle/turtle.cpp @@ -377,7 +377,7 @@ void Turtle::drawPaw(PawType type, PawPosition pos) { assert(m_underneathPixelBuffer != nullptr); KDCoordinate pawOffset = 5; constexpr float crawlOffset = 0.6f; - constexpr float angles[] = {M_PI_2/2, M_PI_2+M_PI_2/2, -M_PI_2-M_PI_2/2, -M_PI_2/2}; + constexpr float angles[] = {M_PI_4, 3*M_PI_4, -3*M_PI_4, -M_PI_4}; // Compute the paw offset from the turtle center float currentAngle = angles[(int) type];