Lua Math Library (2012-05-18 17:26:28)
reproduced
Tags: Games |
Category: Lua |
Atan2, Sinh, cosh, Tanh 4 should not be used.
Name of function |
Describe |
Example |
Results |
Pi |
Pi |
Math.PI |
3.1415926535898 |
Abs |
Take absolute value |
Math.Abs (-2012) |
2012 |
Ceil |
Rounding up |
Math.ceil (9.1) |
10 |
Floor |
Rounding down |
Math.floor (9.9) |
9 |
Max |
Take parameter Maximum value |
Math.max (2,4,6,8) |
8 |
Min |
Take the minimum value of the parameter |
Math.min (2,4,6,8) |
2 |
Pow |
Calculates the y power of X |
Math.pow (2,16) |
65536 |
sqrt |
Open Square |
MATH.SQRT (65536) |
256 |
MoD |
Take the mold |
Math.mod (65535,2) |
1 |
Modf |
Taking integers and fractional parts |
MATH.MODF (20.12) |
20 0.12 |
Randomseed |
Set random number Seed |
Math.randomseed (Os.time ()) |
|
Random |
Take a random number |
Math.random (5,90) |
5~90 |
Rad |
Angle to radians |
Math.rad (180) |
3.1415926535898 |
Deg |
Radian to Angle |
Math.deg (Math.PI) |
180 |
Exp |
E's X-square |
Math.exp (4) |
54.598150033144 |
Log |
Calculates the natural logarithm of X |
Math.log (54.598150033144) |
4 |
Log10 |
Calculates the logarithm of 10 for the base and X |
MATH.LOG10 (1000) |
3 |
Frexp |
Splits the parameter into the form x * (2 ^ y) |
Math.frexp (160) |
0.625 8 |
Ldexp |
Calculate x * (2 ^ y) |
Math.ldexp (0.625,8) |
160 |
Sin |
Sinusoidal |
Math.sin (Math.rad (30)) |
0.5 |
Cos |
Cosine |
Math.Cos (Math.rad (60)) |
0.5 |
Tan |
Tangent |
Math.tan (Math.rad (45)) |
1 |
Asin |
Anyway chord |
Math.deg (Math.asin (0.5)) |
30 |
ACOs |
Inverse cosine |
Math.deg (Math.acos (0.5)) |
60 |
Atan |
Anyway cut |
Math.deg (Math.atan (1)) |
45 |
LUA Math Library