Math and Random Subpackage (math and random)
The math and random modules provide mathematical operations and pseudo-random number generation.
Math API Reference (math)
math.sqrt(x: Float): Float
Computes the square root of double-precision floating-point number x.
math.abs(x: Float): Float
Computes the absolute value of floating-point number x.
math.floor(x: Float): Float
Returns the largest integer value less than or equal to x.
math.ceil(x: Float): Float
Returns the smallest integer value greater than or equal to x.
math.clamp(x: Float, min: Float, max: Float): Float
Clamps a value within the inclusive range [min, max].
math.lerp(start: Float, end: Float, t: Float): Float
Computes linear interpolation between start and end with factor t: start + (end - start) * t.
math.min(a: Float, b: Float): Float
Returns the minimum of two values.
math.max(a: Float, b: Float): Float
Returns the maximum of two values.
math.dot(v1: [Float], v2: [Float]): Float
Computes the vector dot product of two numerical vectors / arrays.
const v1 = [1.0, 2.0, 3.0]
const v2 = [4.0, 5.0, 6.0]
const dot_product = math.dot(v1, v2) // Returns 32.0
math.norm(v: [Float]): Float
Computes the Euclidean $L_2$ norm of a numerical vector.
Random API Reference (random)
random.int(min: Int, max: Int): Int
Generates a pseudo-random 64-bit signed integer in the closed range [min, max].
random.float(): Float
Generates a pseudo-random double-precision floating-point value in the half-open range [0.0, 1.0).