math
At some point, you are likely going to need to change some numbers around. Many mathematical functions such as sine or cosine are provided by Lua. To better understand the provided functions, this section will review Lua's math library.
Note
The official math library documentation is online here: https://www.lua.org/manual/5.2/manual.html#pdf-math
Trigonometry
Some interactive applications such as games rely heavily on trigonometry. Trigonometry is used to figure out the distance between two points, to render a world, and much more. Lua provides the following trig functions. Remember, all of these functions return radians, not degrees:
math.acos(v)
: returns the inverse cosine of a number in radiansmath.asin(v)
: returns the inverse sine of a number in radiansmath.atan(v)
: returns the inverse tangent of a number in radians;v
is assumed to bex / y
math.atan(x, y)
: returns the inverse tangent of a number in radiansmath.cos(v)
: returns the cosine of a number in radiansmath.sin(v)
: returns the...