Published Oct 18, 2023
Contribute to Docs
rad() function in Lua’s math library converts a number given in degrees to its equivalent in radians.
degree: The number in degrees.
In this example,
math.rad() converts 180 degrees to radians.
local x = 180local answer = math.rad(x)local output = string.format("%.0f in radians is %.4f", x, answer)print(output)
This will result in the following output below.
180 in radians is 3.1416
Learn Lua on Codecademy
Computer ScienceLooking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
Includes 6 Courses
With Professional Certification
Beginner Friendly82 Lessons