Game Development Reference
In-Depth Information
math.pow (x,y)
This returns the number that is the result of raising the number x to y (i.e., x y ).
print(math.pow(3,3)) -- 27 => 3^3
print(math.pow(5,2)) -- 25 => 5^5
math.rad (x)
This returns the angle x converted into radians.
print(math.rad(math.pi)) -- 3.1415296535898
math.random ( [m [,n]] )
This returns a random value in the range between m and n . If the values of m and n are not passed,
then the function returns a value between 0 and 1. If a single value is passed to this function, then an
integer value between 1 and this number is returned.
print(math.random()) -- A decimal value between 0 and 1
print(math.random(10)) -- An integer value between 1 and 10
print(math.random(5,25)) -- An integer value between 5 and 25
math.randomseed (x)
This sets the seed for the random number generator. If you seed the value, you can get the same
random values.
math.sin (x)
This returns the sine of an angle passed in radians.
print(math.sin(30)) -- (−0.98803162409286)
math.sinh (x)
This returns the hyperbolic sine of a value.
print(math.sinh(1)) -- 1.1752011936438
math.sqrt (x)
This returns the square root of the number specified by x .
print(math.sqrt(144)) -- 12
print(math.sqrt(9)) -- 3
 
Search WWH ::




Custom Search