3.23. Lua math functions

Notatka: When defining your own parameters (see Sekcja 3.16) can next to basic arithmetic, use more complex mathematical functions. Used for this library math , in which the functions are defined.

Below is a list of features that you can use when you define. To use them, you have to prefix their name a reference to the library math , or use the sqrt function " " (root calculation), you must enter:

math.sqrt(100)

Tabela 3-1. Lua functions to create your own parameters

FunctionsThe result of the functionExample of use
abs(x)the absolute value of x
math.abs(4)
sin(x), cos(x), tan(x)sinus, cosinus, tangens angle x given in radians
math.sin(0)
asin(x), acos(x), atan(x)arcus sinus, arcus cosinus, arcus tangens values x
math.asin(1)
sinh(x), cosh(x), tanh(x)sinus hiperboliczny, cosinus hiperboliczny, tangens hiperboliczny values x
math.sinh()
ceil(x), floor(x)functions rounding the number x to the nearest integer, respectively, up and down
math.ceil(4.5)
deg(x), rad(x)conversion from radians to degrees (deg), and the degrees to radians (rad)
math.rad(90)
exp(x)raise to the power of x
math.exp(3)
log(x)the natural logarithm of x
math.log(10)
log10(x)logarithm base 10 of x
math.log10(100)
pow(x,y)x raised to the power of y (you can also use x ^ y)
math.pow(2,3)
sqrt(x)square root of x
math.sqrt(9)
min(x,y,z)the minimum value of the specified list of arguments
math.min(7,4,12)
max(x,y,z)the minimum value of the specified list of arguments
math.max(3,4.5,1)
modf(x)two arguments - the total value of x and the value after the decimal point
math.modf(5.3)
random([x],[y])random value in the range (0, 1) when running without an argument, (0, x) - given one argument, (x, y) - are two arguments
math.random(23,80)
hugeinfinity (sometimes may be useful in combination with the trigonometric functions)
math.huge
piconstant pi
math.pi

More about writing your own functions you can read in the chapter LUA definable parameters documentSZARP System - technical documentation.