math.acos
Defined in module
"math"from "math" import acosReturns the arccosine of x
Parameters
x | number | value whose arccosine is wanted |
Return value
The arccosine of x, in the range [0, PI], always as a float.
Notes
The mathematical arccosine is only defined for x in [-1, 1]; C's acos answers a domain error with nan outside it. Quirrel avoids that: x is clamped to [-1, 1] before the call, so acos(2) quietly returns the same value as acos(1) instead of nan.
Example
from "math" import acos
println("acos(1) =", acos(1))
println("acos(0.5) =", acos(0.5))
println("acos(-1) =", acos(-1))
// out of [-1, 1], the argument is clamped instead of returning nan
println("acos(2) == acos(1) =", acos(2) == acos(1))
println("acos(-2) == acos(-1) =", acos(-2) == acos(-1))Output:
acos(1) = 0
acos(0.5) = 1.0472
acos(-1) = 3.14159
acos(2) == acos(1) = true
acos(-2) == acos(-1) = trueSee also
asin | Returns the arcsine of x |
atan | Returns the arctangent of x |
cos | Returns the cosine of x (in radians) |
PI | The ratio of a circle's circumference to its diameter, for converting between radians and degrees and for angle math in general. |
| math | module index |