From 3f823c7c6b5548eae6aebce0b6eb9f633a48337e Mon Sep 17 00:00:00 2001 From: ctzsnooze Date: Thu, 28 Nov 2024 13:22:50 +1100 Subject: [PATCH] Reduce ITCM RAM footprint considerably --- src/main/common/maths.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/common/maths.c b/src/main/common/maths.c index d47acd6ab9..da04119e84 100644 --- a/src/main/common/maths.c +++ b/src/main/common/maths.c @@ -54,8 +54,8 @@ float sin_approx(float x) { // Wrap angle to 2π with range [-π π] x = fmodf(x, 2.0f * M_PIf); - if (x <= -M_PIf) x += 2.0f * M_PIf; - if (x > M_PIf) x -= 2.0f * M_PIf; + while (x > M_PIf) x -= (2.0f * M_PIf); // always wrap input angle to -PI..PI + while (x < -M_PIf) x += (2.0f * M_PIf); // Use axis symmetry around x = ±π/2 for polynomial outside of range [-π/2 π/2] if (x > M_PIf / 2) {