A few definitions:
-
Tau: Mathematical constant equivalent to 2 * pi
-
Radian: A unit of measurement used for the circumference of a circle, it is equivalent to the radius wrapped around the circumference and is ~ 59.3 degrees. To convert from degrees to radians you multiply by pi and divide by 180. To convert radians into degrees you multiply by 180 and divide by pi. There are tau radians in the whole circumference of a circle, and therefore pi radians in half a circle.
-
Sign: “Direction” of a number i.e. positive or negative. This can be found by doing
math.sign(x: number)
, it will return -1 for negative, 0 for 0 and 1 for positive.
-
Cosine: This is the ratio of hypotenuse to adjacent (hypotenuse divided by adjacent) (see triangle image).
-
Sine: This is the ratio of opposite to hypotenuse (again see triangle image).
-
Tangent: This is the ratio of opposite to adjacent (again see triangle image).
-
E: Euler’s number is a mathematical constant roughly equal to 2.71828 and is used in many things such as the natural logarithm (more detail under math.log())
math.acos(x: number)
This provides the arc cosine of the number x, the inverse of the cosine.
math.asin(x: number)
This provides the arc sine of the number x, the inverse of the sine. I.e. It takes the ratio of opposite to hypotenuse and returns the angle.
math.atan(x: number)
This provides the arc tangent of the number x, the inverse of the tangent in radians. I.e. It takes the ratio of opposite to adjacent and returns the angle
math.atan2(x: number)
This provides the arc tangent of y/x, the inverse of the tangent but uses the signs to determine the quadrant in radians. Because of this, it can handle x being 0.
math.cosh(x: number)
This provides the hyperbolic cosine of x. This is a complex one so I won’t go into detail, but it is the cosine relative to a hyperbola as opposed to a circle. This is equal to:
cosh(x) = (e^x + e^(-x)) / 2
math.exp(x: number)
This gives you e^x, and as such can be used to find e by doing math.exp(1)
.
math.log(x: number, base: number = e)
This gives you the logarithm of x using the base, the base defaults to e for the natural logarithm. A logarithm is a the inverse of an indices (aka exponent). This means that you can use it to find what power was used:
math.log(8, 2) -- This is 3, because 2^3 is 8
math.log10(x: number)
This provides the base-10 (decimal aka “normal” number base) logarithm of x. Therefore, the following lines are the same:
math.log(x, 10)
math.log10(x)
math.sin(x: number)
This provides the sine of x (see definitions).
math.sinh(x: number)
This provides the hyperbolic sine of x. This is a complex one so I won’t go into detail, but it is the cosine relative to a hyperbola as opposed to a circle. This is equal to:
sinh(x) = (e^x - e^(-x)) / 2
math.modf(x: number)
There is no math.mod()
function so I assume this is what you mean. It returns the integral and fractional parts of x. I.e. It splits a number into a whole and a decimal. For example, 2.3 → 2, 0.3. For whole numbers it will return the number and 0 e.g. 2 → 2, 0
math.tan(x: number)
This provides the tangent of x (see definitions).
math.tanh(x: number)
This provides the hyperbolic tangent of x. This is a complex one so I won’t go into detail, but it is the cosine relative to a hyperbola as opposed to a circle. This is equal to:
tanh(x) = sinh(x) / cosh(x)