math.atan

Returns the arctangent (inverse tangent) of num (in radians). This is equivalent to . To convert the output to degrees, you can use math.deg (for example: math.deg(math.atan(0.5))).

Namearctangent
Lua functionmath.atan
Usual notation
Definition
Domain of x for real resultall real numbers
Range of usual principal value
(radians)
ExamplePrint the arctangent of user input
Read a line from the user, print its arctangent in radians, then in degrees.
Code
<nowiki>
local num = math.atan(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 0.46364760900081 and 26.565051177078.

math.atan
Function
Syntax
math.atan(
  • 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.