# Difference between revisions of "Lua/Math Functions"

From Serious Sam Wiki

< Lua

(Created page with "Here is a list of some useful math functions from Serious Engine which can be used in Lua scripts. * '''''mthAbsF(x)''''' - Returns the absolute value of number x. * '...") |
Innocentive (Talk | contribs) (added category) |
||

Line 41: | Line 41: | ||

* '''''mthRndF()''''' - Returns a random number in range 0.0 - 1.0 range. | * '''''mthRndF()''''' - Returns a random number in range 0.0 - 1.0 range. | ||

+ | |||

+ | [[Category:Old Pages]] |

## Latest revision as of 12:02, 1 May 2016

Here is a list of some useful math functions from Serious Engine which can be used in Lua scripts.

*- Returns the absolute value of number x. *mthAbsF(x)- Returns sign of a number (-1/0/+1 for x<0/x=0/x>0). *mthSgnF(x)- Returns the floor (first integer lower or equal to) of number x. *mthFloorF(x)- Returns fractional part of a floating point number x. *mthFracF(x)- Returns the ceiling (first integer higher or equal to) of number x. *mthCeilF(x)- Returns the nearest integer of number x. *mthRoundF(x)- Returns the maximum of two numbers x and y. *mthMaxF(x,y)- Returns the minimum of two numbers x and y. *mthMinF(x,y)- Returns the value of x clamped down to the downLimit. *mthClampDnF(x, downLimit)- Returns the value of x clamped up to the upLimit. *mthClampUpF(x, upLimit)- Returns the value of x clamped to the interval defined with downLimit and upLimit.mthClampF(x, downLimit, upLimit)

*- Returns the value of Sine function of angle x expressed in radians. *mthSinF(x)- Returns the value of Cosine function of angle x expressed in radians. *mthCosF(x)- Returns the value of Tangent function of angle x expressed in radians. *mthTanF(x)- Returns the value of Arcus Sine function of value x, in radians. *mthASinF(x)- Returns the value of Arcus Cosine function of value x, in radians. *mthACosF(x)- Returns the value of Arcus Tangent function of value x, in radians.mthATanF(x)

*- Returns the square root of a positive number x. *mthSqrtF(x)- Returns the square root of a number x (0 or the number is negative).mthSafeSqrt(x)

*- Returns natural logarithm of a number x. *mthLogEF(x)- Returns decimal logarithm of a number x. *mthLog10F(x)- Returns base 2 logarithm of a number x. *mthLog2F(x)- Returns base b logarithm of a number x. *mthLogAF(b, x)- Returns 2 to the x-th power. *mthPow2F(x)- Returns 10 to the x-th power. *mthPow10F(x)- Returns E to the x-th power.mthPowEF(x)

*- Converts angle x from degrees to radians. *mthDegToRad(x)- Converts angle x from radians to degrees.mthRadToDeg(x)

*- Returns a random number in range 0.0 - 1.0 range.mthRndF()