Quirrel4.41.0

math.asin

Defined in module "math"
from "math" import asin
pure fastcall asin(x: number): float

Returns the arcsine of x

Parameters

xnumbervalue whose arcsine is wanted

Return value

The arcsine of x, in the range [-PI/2, PI/2], always as a float.

Notes

The mathematical arcsine is only defined for x in [-1, 1]; C's asin answers a domain error with nan outside it. Quirrel avoids that: x is clamped to [-1, 1] before the call, so asin(2) quietly returns the same value as asin(1) instead of nan.

Example

examples/math/asin.nut
from "math" import asin

println("asin(0) =", asin(0))
println("asin(0.5) =", asin(0.5))
println("asin(1) =", asin(1))

// out of [-1, 1], the argument is clamped instead of returning nan
println("asin(2) == asin(1) =", asin(2) == asin(1))
println("asin(-2) == asin(-1) =", asin(-2) == asin(-1))
Output:
asin(0) = 0
asin(0.5) = 0.523599
asin(1) = 1.5708
asin(2) == asin(1) = true
asin(-2) == asin(-1) = true

See also

acosReturns the arccosine of x
atanReturns the arctangent of x
sinReturns the sine of x (in radians)
PIThe ratio of a circle's circumference to its diameter, for converting between radians and degrees and for angle math in general.
mathmodule index