math.atan

From ComputerCraft
Jump to navigation Jump to search

math.atan
Function
Syntax
math.atan()
Returns number
API math
Source Lua (source)

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)
Error creating thumbnail: Unable to save thumbnail to destination
ExamplePrint the arctangent of user input
Read a line from the user, print its arctangent in radians, then in degrees.
Code
local num = math.atan(tonumber(read()))
print(num)
print(math.deg(num))
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.