diff --git a/atan2.go b/atan2.go index 3da4f6d46c36f716bbe9d4a2072cc59d85151158..a1990ca8abebee00db17e11004e90b239c365807 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))) }