math.asin

Shared

Returns the arc sine of a number in radians


Syntax

local result = math.asin(
    value
)

Parameters

TypeNameDescription
numbervalueSine value in the range [-1, 1]

Returns

TypeNameDescription
numberresultArc sine in radians, in the range [-pi/2, pi/2]

Examples

Arc sine of 0
local result = math.asin(0)

engine.print("info", result) -- 0.0
Arc sine of 1 is pi/2
local result = math.asin(1)

engine.print("info", result) -- 1.5707963267949
Arc sine of 0.5 is 30 degrees
local result = math.deg(math.asin(0.5))

engine.print("info", result) -- 30.0
Arc sine of -1 is -pi/2
local result = math.asin(-1)

engine.print("info", result) -- -1.5707963267949
Recover angle from a vertical direction component
local dir_y = 0.866 -- sin(60 degrees)
local angle_deg = math.deg(math.asin(dir_y))

engine.print("info", angle_deg) -- 59.999
Verify asin and sin are inverses
local angle = math.pi / 6
local result = math.asin(math.sin(angle))

engine.print("info", result) -- 0.5235987755983

On this page