Skip to content

Commit 4ff94e6

Browse files
committed
Add protection for fastTAtan2(0,0) call
1 parent 792c0d0 commit 4ff94e6

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Common/MathUtils/include/MathUtils/detail/trigonometric.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,10 @@ GPUhdi() constexpr T fastATan2(T y, T x)
298298
T tan = 0;
299299
if (xx < 0) { // p1 is in the range [Pi/4, 3*Pi/4]
300300
phi0 = Pi075;
301-
tan = -x1 / y1;
301+
tan = y1 > T(0) ? -x1 / y1 : T(0); // yy is always >=0, hence y1>=0
302302
} else { // p1 is in the range [-Pi/4, Pi/4]
303303
phi0 = Pi025;
304-
tan = y1 / x1;
304+
tan = x1 > T(0) ? y1 / x1 : T(0);
305305
}
306306
return phi0 + atan(tan);
307307
};

0 commit comments

Comments
 (0)