From 4ff94e6ebdce7650e2c9b72e912724aca34e39dc Mon Sep 17 00:00:00 2001 From: shahoian Date: Wed, 29 Jul 2026 16:53:28 +0200 Subject: [PATCH] Add protection for fastTAtan2(0,0) call --- Common/MathUtils/include/MathUtils/detail/trigonometric.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Common/MathUtils/include/MathUtils/detail/trigonometric.h b/Common/MathUtils/include/MathUtils/detail/trigonometric.h index 68d002320df2e..e13d965663dc9 100644 --- a/Common/MathUtils/include/MathUtils/detail/trigonometric.h +++ b/Common/MathUtils/include/MathUtils/detail/trigonometric.h @@ -298,10 +298,10 @@ GPUhdi() constexpr T fastATan2(T y, T x) T tan = 0; if (xx < 0) { // p1 is in the range [Pi/4, 3*Pi/4] phi0 = Pi075; - tan = -x1 / y1; + tan = y1 > T(0) ? -x1 / y1 : T(0); // yy is always >=0, hence y1>=0 } else { // p1 is in the range [-Pi/4, Pi/4] phi0 = Pi025; - tan = y1 / x1; + tan = x1 > T(0) ? y1 / x1 : T(0); } return phi0 + atan(tan); };