math.acos
Shared
Returns the arc cosine of a number in radians
Syntax
local result = math.acos(
value
)Parameters
| Type | Name | Description |
|---|---|---|
number | value | Cosine value in the range [-1, 1] |
Returns
| Type | Name | Description |
|---|---|---|
number | result | Arc cosine in radians, in the range [0, pi] |
Examples
local result = math.acos(1)
engine.print("info", result) -- 0.0local result = math.acos(0)
engine.print("info", result) -- 1.5707963267949local result = math.acos(-1)
engine.print("info", result) -- 3.1415926535898local result = math.deg(math.acos(0.5))
engine.print("info", result) -- 60.0local dot_product = 0.5
local angle_deg = math.deg(math.acos(dot_product))
engine.print("info", angle_deg) -- 60.0local angle = math.pi / 3
local result = math.acos(math.cos(angle))
engine.print("info", result) -- 1.0471975511966