From 346853ee55ddb3752293429293637b5c61849345 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 4 Nov 2024 17:41:35 +0200 Subject: [PATCH] BAN: Implement sincos to math This function calculates both sin and cos fast (hopefully) --- BAN/include/BAN/Math.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/BAN/include/BAN/Math.h b/BAN/include/BAN/Math.h index 87f09b50a0..0a663471c2 100644 --- a/BAN/include/BAN/Math.h +++ b/BAN/include/BAN/Math.h @@ -325,7 +325,6 @@ namespace BAN::Math template inline constexpr T sin(T x) { - x = fmod(x, (T)2.0 * numbers::pi_v); asm("fsin" : "+t"(x)); return x; } @@ -333,12 +332,16 @@ namespace BAN::Math template inline constexpr T cos(T x) { - if (abs(x) >= (T)9223372036854775808.0) - x = fmod(x, (T)2.0 * numbers::pi_v); asm("fcos" : "+t"(x)); return x; } + template + inline constexpr void sincos(T x, T& sin, T& cos) + { + asm("fsincos" : "=t"(cos), "=u"(sin) : "0"(x)); + } + template inline constexpr T tan(T x) {