From 46cb953c36dc109ca0089dd10babbaf7ee290cae Mon Sep 17 00:00:00 2001 From: Chewxy <chewxy@gmail.com> Date: Fri, 2 Jul 2021 09:17:39 +1000 Subject: [PATCH] Fixed #21 (#22) --- atan2.go | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/atan2.go b/atan2.go index 3da4f6d..a1990ca 100644 --- a/atan2.go +++ b/atan2.go @@ -2,6 +2,25 @@ package math32 import "math" -func Atan2(x, y float32) float32 { - return float32(math.Atan2(float64(x), float64(y))) +// Atan2 returns the arc tangent of y/x, using the signs of the two to determine the quadrant of the return value. +// Special cases are (in order): +// Atan2(y, NaN) = NaN +// Atan2(NaN, x) = NaN +// Atan2(+0, x>=0) = +0 +// Atan2(-0, x>=0) = -0 +// Atan2(+0, x<=-0) = +Pi +// Atan2(-0, x<=-0) = -Pi +// Atan2(y>0, 0) = +Pi/2 +// Atan2(y<0, 0) = -Pi/2 +// Atan2(+Inf, +Inf) = +Pi/4 +// Atan2(-Inf, +Inf) = -Pi/4 +// Atan2(+Inf, -Inf) = 3Pi/4 +// Atan2(-Inf, -Inf) = -3Pi/4 +// Atan2(y, +Inf) = 0 +// Atan2(y>0, -Inf) = +Pi +// Atan2(y<0, -Inf) = -Pi +// Atan2(+Inf, x) = +Pi/2 +// Atan2(-Inf, x) = -Pi/2 +func Atan2(y, x float32) float32 { + return float32(math.Atan2(float64(y), float64(x))) } -- GitLab