From 2051eebdb1271db06b09b4236156136ccbcdbf84 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 8 Feb 2018 10:46:01 +0000 Subject: [PATCH 1/2] fix atan264 for negative y and positive x when y is negative and x is positive the output should be negative, this addresses both: https://github.com/mmoller2k/Math64/issues/1 and https://github.com/vtomanov/Gps64/issues/1 --- Math64.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Math64.cpp b/Math64.cpp index 255e08f..231ee03 100644 --- a/Math64.cpp +++ b/Math64.cpp @@ -172,7 +172,7 @@ f64 atan264(f64 y, f64 x) if(x.isZero() && !y.isNegative()) return pio2; if(y.isNegative() && x.isNegative()) return atan64(y/x)-pio2*f64(2); if(x.isNegative()) return atan64(y/x)+pio2*f64(2); // y>=zero - + if(y.isNegative() && !x.isNegative()) return -atan64(y/x); return atan64(y/x); // x>zero } From 769cd0b7595430d663d58b67e8b73379652537f3 Mon Sep 17 00:00:00 2001 From: James Date: Thu, 8 Feb 2018 11:43:25 +0000 Subject: [PATCH 2/2] fix asin64 to return neg value with neg input --- Math64.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Math64.cpp b/Math64.cpp index 231ee03..6be595d 100644 --- a/Math64.cpp +++ b/Math64.cpp @@ -156,6 +156,8 @@ f64 asin64(f64 z) z=z/sqrt64(f64(1)-z*z); + if (z<0) + return -atan64(z); return atan64(z); }