math.acos

Return the arccos (inverse cosine) of num (in radians). This is equivalent to . To convert the output to degrees, you can use math.deg (for example: math.deg(math.acos(0.5))).

Namearccos
Lua functionmath.acos
Usual notation
Definition
Domain of x for real result
Range of usual principal value
(radians)
ExamplePrint the arccosine of user input
Read a line from the user, print its arccos in radians, then in degrees.
Code
<nowiki>local num = math.acos(tonumber(read()))
print(num)
print(math.deg(num))
    </nowiki>
Output Depends on what the user wrote. For instance, if they were to enter 0.5, the numbers printed would be 1.0471975512 () and 60.

math.acos
Function
Syntax
math.acos(
  • num : number
)

Returns number
API math
Source Lua (source)
This article is issued from Computercraft. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.