The math library is a standard Lua library that provides functions for manipulating numbers. In Garry's Mod several additional math functions have been added.
Calculates the absolute value of a number (effectively removes any negative sign).
Gradually approaches the target value by the specified amount.
Increments an angle towards another by specified rate.
functions like math.atan(y / x), except it also takes into account the quadrant of the angle and so doesn't have a limited range of output.
Clamps a number between a minimum and maximum value
Returns the difference between two points in 2D space.
Calculates the progress of a value fraction, taking in to account given easing fractions
Returns the modulus of the specified values.
While this is similar to the % operator, it will return a negative value if the first argument is negative, whereas the % operator will return a
positive value even if the first operand is negative.
<-- Lua reference description: Returns m and e such that x = m2e, e is an integer and the absolute value of m is in the range ((0.5, 1) (or zero when x is zero). --> Used to split the number value into a normalized fraction and an exponent. Two values are returned: the first is a multiplier in the range 1/2 (inclusive) to 1 (exclusive) and the second is an integer exponent.
The result is such that x = m*2^e.
Takes a normalised number and returns the floating point representation.
With one argument, return the natural logarithm of x (to base e).
With two arguments, return the logarithm of x to the given base, calculated as log(x)/log(base).
Returns the base-10 logarithm of x. This is usually more accurate than math.log(x, 10).
Returns the integral and fractional component of the modulo operation.
Normalizes angle, so it returns value between -180 and 180.
Returns x raised to the power y. In particular, math.pow(1.0, x) and math.pow(x, 0.0) always return 1.0, even when x is a zero or a nan. If both x and y are finite, x is negative, and y is not an integer then math.pow(x, y) is undefined.
Returns a random float between min and max.
See also math.random
When called without arguments, returns a uniform pseudo-random real number in the range 0 to 1 which includes 0 but excludes 1.
When called with an integer number m, returns a uniform pseudo-random integer in the range 1 to m inclusive.
When called with two integer numbers m and n, returns a uniform pseudo-random integer in the range m to n inclusive.
See also math.Rand
Remaps the value from one range to another
Rounds the given value to the nearest whole number or to the given decimal places.
Returns the fraction of where the current time is relative to the start and end times