Lua/Math Functions

From Serious Sam Wiki
< Lua
Jump to: navigation, search

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.
  
  * mthSgnF(x) - Returns sign of a number (-1/0/+1 for x<0/x=0/x>0).
  
  * mthFloorF(x) - Returns the floor (first integer lower or equal to) of number x.
  * mthFracF(x) - Returns fractional part of a floating point number x.
  * mthCeilF(x) - Returns the ceiling (first integer higher or equal to) of number x.
  * mthRoundF(x) - Returns the nearest integer of number x.
  
  * mthMaxF(x,y) - Returns the maximum of two numbers x and y.
  * mthMinF(x,y) - Returns the minimum of two numbers x and y.
  
  * mthClampDnF(x, downLimit) - Returns the value of x clamped down to the downLimit.
  * mthClampUpF(x, upLimit) - Returns the value of x clamped up to the upLimit.
  * mthClampF(x, downLimit, upLimit) - Returns the value of x clamped to the interval defined with downLimit and upLimit.
  * mthSinF(x) - Returns the value of Sine function of angle x expressed in radians.
  * mthCosF(x) - Returns the value of Cosine function of angle x expressed in radians.
  * mthTanF(x) - Returns the value of Tangent function of angle x expressed in radians.
  
  * mthASinF(x) - Returns the value of Arcus Sine function of value x, in radians.
  * mthACosF(x) - Returns the value of Arcus Cosine function of value x, in radians.
  * mthATanF(x) - Returns the value of Arcus Tangent function of value x, in radians.
  * mthSqrtF(x) - Returns the square root of a positive number x.
  * mthSafeSqrt(x) - Returns the square root of a number x (0 or the number is negative).
  * mthLogEF(x) - Returns natural logarithm of a number x.
  * mthLog10F(x) - Returns decimal logarithm of a number x.
  * mthLog2F(x) - Returns base 2 logarithm of a number x.
  * mthLogAF(b, x) - Returns base b logarithm of a number x.
  
  * mthPow2F(x) - Returns 2 to the x-th power.
  * mthPow10F(x) - Returns 10 to the x-th power.
  * mthPowEF(x) - Returns E to the x-th power.
  * mthDegToRad(x) - Converts angle x from degrees to radians.
  * mthRadToDeg(x) - Converts angle x from radians to degrees.
  * mthRndF() - Returns a random number in range 0.0 - 1.0 range.