PcoWSkbVqDnWTu_dm2ix
We use cookies on this site to enhance your user experience
Collapse Sidebar

math

Functions

number math.abs ( number x )

Returns the absolute value of x

number math.acos ( number x )

Returns the arc cosine of x

number math.asin ( number x )

Returns the arc sine of x

number math.atan ( number x )

Returns the arc tangent of x (in radians)

number math.atan2 ( number y, number x )

Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result. It also handles correctly the case of x being zero.

int math.ceil ( number x )

Returns the smallest integer larger than or equal to x.

number math.clamp ( number x, number min, number max )

Returns a number between min and max, inclusive.

number math.cos ( number x )

Returns the cosine of x (assumed to be in radians).

number math.cosh ( number x )

Returns the hyperbolic cosine of x.

number math.deg ( number x )

Returns the angle x (given in radians) in degrees.

number math.exp ( number x )

Returns the value e^x.

int math.floor ( number x )

Returns the largest integer smaller than or equal to x.

number math.fmod ( number x, number y )

Returns the remainder of the division of x by y that rounds the quotient towards zero.

number, int math.frexp ( number x )

Returns m and e such that x = m*2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).

number math.ldexp ( number x, int e )

Returns m*2^e (e should be an integer).

number math.log ( number x )

Returns the natural logarithm of x.

number math.log10 ( number x )

Returns the base-10 logarithm of x.

number math.max ( number x, number ... )

Returns the maximum value among the numbers passed to the function.

number math.min ( number x, number ... )

Returns the minimum value among the numbers passed to the function.

number, number math.modf ( number x )

Returns two numbers, the integral part of x and the fractional part of x.

number math.noise ( number x = 0, number y = 0, number z = 0 )

Returns a perlin noise value between -0.5 and 0.5. If you leave arguments out, they will be interpreted as zero, so math.noise(1.158) is equivalent to math.noise(1.158, 0, 0) and math.noise(1.158, 5.723) is equivalent to math.noise(1.158, 5.723, 0).

The function uses a perlin noise algorithm to assign fixed values to coordinates. For example, math.noise(1.158, 5.723) will always return 0.48397532105446 and math.noise(1.158, 6) will always return 0.15315161645412.

If x, y and z are all integers, the return value will be 0. For fractional values of x, y and z, the return value will gradually fluctuate between -0.5 and 0.5. For coordinates that are close to each other, the return values will also be close to each other.

number math.pow ( number x, number y )

Returns x^y. (You can also use the expression x^y to compute this value.)

number math.rad ( number x )

Returns the angle x (given in degrees) in radians.

number math.random ( number m = 0.0, number n = 1.0 )

This function is an interface to the simple pseudo-random generator function rand provided by ANSI C. (No guarantees can be given for its statistical properties.) When called without arguments, returns a uniform pseudo-random real number in the range [0,1). When called with an integer number m, math.random returns a uniform pseudo-random integer in the range [1, m]. When called with two integer numbers m and n, math.random returns a uniform pseudo-random integer in the range [m, n].

void math.randomseed ( number x )

Sets x as the seed for the pseudo-random generator: equal seeds produce equal sequences of numbers.

int math.sign ( number x )

Returns -1 if x < 0, 0 if x == 0, or 1 if x > 0.

number math.sin ( number x )

Returns the sine of x (assumed to be in radians).

number math.sinh ( number x )

Returns the hyperbolic sine of x.

number math.sqrt ( number x )

Returns the square root of x. (You can also use the expression x^0.5 to compute this value.)

number math.tan ( number x )

Returns the tangent of x (assumed to be in radians).

number math.tanh ( number x )

Returns the hyperbolic tangent of x.

Constants

number math.huge

The value HUGE_VAL, a value larger than or equal to any other numerical value.

number math.pi

The value of pi.