xyosc/vendor/github.com/chewxy/math32/asin.go
2024-12-21 17:38:26 +01:00

28 lines
340 B
Go

package math32
func Asin(x float32) float32 {
if x == 0 {
return x // special case
}
sign := false
if x < 0 {
x = -x
sign = true
}
if x > 1 {
return NaN() // special case
}
temp := Sqrt(1 - x*x)
if x > 0.7 {
temp = Pi/2 - satan(temp/x)
} else {
temp = satan(x / temp)
}
if sign {
temp = -temp
}
return temp
}