developer_center:developer_editor:script:lua_mathlibrary
Lua math library
Random number generation
Method | Description |
---|---|
math.random(x,y) | Returns a pseudorandom number from x to y (y is optional, if there is no y, the value will be generated from 1 to x) |
math.randomseed(x) | Sets x as the seed for the pseudo-random seed number generator. |
Constants
Method | Description |
---|---|
math.pi | Value of Pi) |
math.huge | equal to Infinite |
Other Mathematical Operations
Method | Description |
---|---|
math.abs(x) | Returns the absolute value of x (negative to positive) |
math.sqrt(x) | Returns the Square root of X |
math.max(x,…) | Returns the maximun value from its arguments eg math.max(99,54,23,15,233) → 223 |
math.min(x,…) | Returns the minimun value from its arguments eg math.max(99,54,23,15,233) → 15 |
Rounding and remainder
Method | Description |
---|---|
math.floor(x) | Returns the largest integer smaller than or equal to x |
math.ceil(x) | Returns the smallest integer larger than or equal to x |
math.modf(x) | Returns the integral part of x and the fractional part of x. eg: math.modf(12.321) returns 12 and 0.321 |
math.fmod(x,y) | Returns the remainder of the division of x by y rounding the quotient towards zero. eg: math.fmod(10.5 , 3.2) returns ≈0.099999999999998 |
Exponential and logarithmic methods
Method | Description |
---|---|
math.exp(x) | Returns the value e raised to the power of x |
math.log(x) | Returns the natural Logarithm of x |
math.log10(x) | Returns the Base 10 logarithm of x |
math.pow(x,y) | Returns x to the power of y |
Trigonometric Methods
Method | Description |
---|---|
math.acos(x) | Returns the Arc cosine of X (in Radians) |
math.asin(x) | Returns the Arc sine of x (in Radians). |
math.atan(x) | Returns the Arc tangent of x (inRadians). |
math.atan2(y,x) | Returns the Arc cosine of Y/X (in Radians) but uses the signs of both y and x to determine the angle's quadrant in the coordinate plane. and also handles the case of x being 0 |
math.cos(x) | Returns the Cosine of x (assumed to be in Radians). |
math.sin(x) | Returns the Sine of x (assumed to be in Radians). |
math.tan(x) | Returns the Tangent of x (assumed to be inRadians). |
math.deg(x) | Returns the angle x (given in radians) to Degrees |
math.rad(x) | Returns the angle x (given in degrees) in Radians. |
developer_center/developer_editor/script/lua_mathlibrary.txt · Last modified: 2024/02/05 21:19 by notsopro