math
This library provides basic mathematical functions. It provides all its functions and constants inside the table math
.
🧑💻API Source
This page is auto-generated! The Functions, Properties and Events described here are defined in our GitHub's API Repository! Feel free to commit suggestions and changes to the source .json API files!
🎒 Examples
TODO Examples
🗼 Static Properties
Value | Name |
---|---|
3.141592653589793 | math.pi |
2^1024 | math.huge |
🗿 Static Functions
Returns | Name | Description | |
---|---|---|---|
number | ceil | Return the integer no greater than the given value (even for negatives) | |
number | tan | Return the tangent value for a given value in radians. | |
number | min | Return the minimum value from a variable length list of arguments | |
number | fmod | Returns the remainder of the division of base by modulator that rounds the quotient towards zero | |
number | exp | Returns e (the base of natural logarithms) raised to the power exponent | |
number | random | Generates pseudo-random numbers uniformly distributed | |
number | rad | Convert from degrees to radians | |
number | sin | Return the sine value for a given value in radians. | |
number | cos | Return the cosine value for a given value in radians. | |
number | asin | Return the inverse sine in radians of the given value. | |
randomseed | Sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers | ||
number | floor | Return the integer no less than the given value (even for negatives) | |
number | max | Return the maximum value from a variable length list of arguments | |
number | atan | Return the inverse tangent in radians. We can do this by supplying y/x ourselves or we can pass y and x to math.atan to do this for us | |
number | acos | Return the inverse cosine in radians of the given value. | |
number | abs | Return the absolute, or non-negative value, of a given value | |
number | log | Returns the inverse of this. math.exp(1) returns e | |
number, number | modf | Return the integral and fractional parts of the given number | |
number | deg | Convert from radians to degrees | |
number | sqrt | Return the square root of a given number. Only non-negative arguments are allowed |
ceil
Return the integer no greater than the given value (even for negatives)
— Returns number.
local ret = math.ceil(number)
Type | Parameter | Default | Description |
---|---|---|---|
number | number | Required parameter | The number to be rounded up. |
tan
Return the tangent value for a given value in radians.
— Returns number.
local ret = math.tan(value)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | Angle in radians |
min
Return the minimum value from a variable length list of arguments
— Returns number.
local ret = math.min(numbers...)
Type | Parameter | Default | Description |
---|---|---|---|
varargs of number | numbers... | Required parameter | Numbers to get the smallest from. |
fmod
Returns the remainder of the division ofbase
bymodulator
that rounds the quotient towards zero
— Returns number.
local ret = math.fmod(base, modulator)
Type | Parameter | Default | Description |
---|---|---|---|
number | base | Required parameter | The base value. |
number | modulator | Required parameter | The modulator. |
exp
Returns e (the base of natural logarithms) raised to the power exponent
— Returns number.
local ret = math.exp(exponent)
Type | Parameter | Default | Description |
---|---|---|---|
number | exponent | Required parameter | The exponent for the function. |
random
Generates pseudo-random numbers uniformly distributed
— Returns number.
local ret = math.random(m, n)
Type | Parameter | Default | Description |
---|---|---|---|
number | m | Required parameter | If m is the only parameter: upper limit. If n is also provided: lower limit. If provided, this must be an integer. |
number | n | Required parameter | Upper limit. If provided, this must be an integer. |
rad
Convert from degrees to radians
— Returns number.
local ret = math.rad(degrees)
Type | Parameter | Default | Description |
---|---|---|---|
number | degrees | Required parameter | The angle measured in degrees. |
sin
Return the sine value for a given value in radians.
— Returns number.
local ret = math.sin(number)
Type | Parameter | Default | Description |
---|---|---|---|
number | number | Required parameter | Angle in radians |
cos
Return the cosine value for a given value in radians.
— Returns number.
local ret = math.cos(number)
Type | Parameter | Default | Description |
---|---|---|---|
number | number | Required parameter | Angle in radians |
asin
Return the inverse sine in radians of the given value.
— Returns number.
local ret = math.asin(normal)
Type | Parameter | Default | Description |
---|---|---|---|
number | normal | Required parameter | Sine value in the range of -1 to 1. |
randomseed
Sets a seed for the pseudo-random generator: Equal seeds produce equal sequences of numbers
math.randomseed(seed)
Type | Parameter | Default | Description |
---|---|---|---|
number | seed | Required parameter | The new seed |
floor
Return the integer no less than the given value (even for negatives)
— Returns number.
local ret = math.floor(number)
Type | Parameter | Default | Description |
---|---|---|---|
number | number | Required parameter | The number to be rounded down. |
max
Return the maximum value from a variable length list of arguments
— Returns number.
local ret = math.max(numbers...)
Type | Parameter | Default | Description |
---|---|---|---|
varargs of number | numbers... | Required parameter | Numbers to get the largest from |
atan
Return the inverse tangent in radians. We can do this by supplying y/x ourselves or we can pass y and x to math.atan to do this for us
— Returns number.
local ret = math.atan(normal)
Type | Parameter | Default | Description |
---|---|---|---|
number | normal | Required parameter | Tangent value. |
acos
Return the inverse cosine in radians of the given value.
— Returns number.
local ret = math.acos(cos)
Type | Parameter | Default | Description |
---|---|---|---|
number | cos | Required parameter | Cosine value in range of -1 to 1. |
abs
Return the absolute, or non-negative value, of a given value
— Returns number.
local ret = math.abs(x)
Type | Parameter | Default | Description |
---|---|---|---|
number | x | Required parameter | The number to get the absolute value of. |
log
Returns the inverse of this.math.exp(1)
returnse
— Returns number.
local ret = math.log(x, base)
Type | Parameter | Default | Description |
---|---|---|---|
number | x | Required parameter | The value to get the base from exponent from. |
number | base | Required parameter | The logarithmic base. |
modf
Return the integral and fractional parts of the given number
— Returns number, number (, ).
local ret_01, ret_02 = math.modf(base)
Type | Parameter | Default | Description |
---|---|---|---|
number | base | Required parameter | The base value. |
deg
Convert from radians to degrees
— Returns number.
local ret = math.deg(radians)
Type | Parameter | Default | Description |
---|---|---|---|
number | radians | Required parameter | Value to be converted to degrees. |
sqrt
Return the square root of a given number. Only non-negative arguments are allowed
— Returns number.
local ret = math.sqrt(value)
Type | Parameter | Default | Description |
---|---|---|---|
number | value | Required parameter | Value to get the square root of. |