Orion Solutions Docs
ORION SOLUTIONS LUA API

Math

Lua math functions and Orion Solutions math helpers.

The math library provides the standard Lua/LuaJIT mathematical functions and Orion Solutions-specific helpers.

abs

math.abs(x: number): number

Returns the absolute value of x.

acos

math.acos(x: number): number

Returns the arc cosine of x in radians.

asin

math.asin(x: number): number

Returns the arc sine of x in radians.

atan

math.atan(x: number): number

Returns the arc tangent of x in radians.

atan2

math.atan2(y: number, x: number): number

Returns the arc tangent of y / x while using the signs of both values to determine the result quadrant.

ceil

math.ceil(x: number): number

Returns the smallest integer greater than or equal to x.

clamp

math.clamp(value: number, min: number, max: number): number
NameTypeDescription
valuenumberValue to clamp.
minnumberMinimum value.
maxnumberMaximum value.

Returns value clamped between min and max. Reversed limits are handled automatically.

cos

math.cos(x: number): number

Returns the cosine of x in radians.

cosh

math.cosh(x: number): number

Returns the hyperbolic cosine of x.

deg

math.deg(x: number): number

Converts an angle from radians to degrees.

exp

math.exp(x: number): number

Returns e raised to the power of x.

floor

math.floor(x: number): number

Returns the largest integer less than or equal to x.

fmod

math.fmod(x: number, y: number): number

Returns the remainder of x / y with the quotient rounded toward zero.

frexp

math.frexp(x: number): number, number

Returns m and e such that x = m * 2^e.

huge

math.huge: number

A numeric value greater than or equal to any other finite numerical value.

ldexp

math.ldexp(m: number, e: number): number

Returns m * 2^e.

log

math.log(x: number): number

Returns the natural logarithm of x.

log10

math.log10(x: number): number

Returns the base-10 logarithm of x.

map

math.map(value: number, in_from: number, in_to: number, out_from: number, out_to: number[, should_clamp: boolean]): number
NameTypeDescription
valuenumberValue to map.
in_fromnumberInput range minimum.
in_tonumberInput range maximum.
out_fromnumberOutput range minimum.
out_tonumberOutput range maximum.
should_clampbooleanOptionally clamps the mapped percentage to the input range.

Linearly maps a value from one numeric range into another.

max

math.max(x: number[, ...]): number

Returns the maximum value among its arguments.

min

math.min(x: number[, ...]): number

Returns the minimum value among its arguments.

modf

math.modf(x: number): number, number

Returns the integral and fractional parts of x.

normalize_yaw

math.normalize_yaw(x: number): number

Normalizes a yaw angle into the range [-180, 180).

pi

math.pi: number

The value of pi.

pow

math.pow(x: number, y: number): number

Returns x raised to the power of y.

rad

math.rad(x: number): number

Converts an angle from degrees to radians.

random

math.random([m[, n]]): number

Returns a pseudo-random number. With no arguments it returns a value in [0, 1); with one or two integer arguments it returns an integer in the requested range.

randomseed

math.randomseed(x: number)

Sets the seed used by the pseudo-random number generator.

sin

math.sin(x: number): number

Returns the sine of x in radians.

sinh

math.sinh(x: number): number

Returns the hyperbolic sine of x.

sqrt

math.sqrt(x: number): number

Returns the square root of x.

tan

math.tan(x: number): number

Returns the tangent of x in radians.

tanh

math.tanh(x: number): number

Returns the hyperbolic tangent of x.

Examples

print(math.abs(-25))
print(math.clamp(150, 0, 100))
print(math.map(50, 0, 100, 0, 1))
print(math.map(150, 0, 100, 0, 1, true))
print(math.normalize_yaw(270))
print(math.rad(180))
print(math.deg(math.pi))