math
dot() function
Compute the dot product between two numeric arrays, returning a scalar. Extra elements are ignored.
project() function
Project one vector onto another, returning a new array of the same dimension.
rotate() function
Rotate a 2D point (or array of length 2) by the given angle (in turns) around an optional pivot.
midpoint() function
Compute the midpoint of two arrays of numbers. Only the first two entries are used if 2D is intended.
reflect() function
Reflect a vector across a plane normal. Both arguments must be numeric arrays.
distance() function
Compute the Euclidean distance between two numeric arrays of matching length.
direction() function
Compute the normalized direction vector from the first array to the second.
angle() function
Given a 2D vector, return its angle from the X-axis in radians or some chosen units.
norm() function
Return a normalized copy of the given numeric array. For 2D/3D/4D or arbitrary length.
angle_between() function
Compute the angle between two vectors (2D/3D/4D).
lerp() function
Linear interpolation between two numbers: lerp(a, b, t).
gcd() function
Compute the greatest common divisor of two integers.
lcm() function
Compute the least common multiple of two integers.
clamp() function
Clamp a number between low and high. clamp(value, low, high).
angledist() function
Compute the signed distance between two angles in 'turn' units, e.g. 0..1 range.
jitter() function
Apply a random +/- percentage noise to a number. Example: jitter(100, 0.05) -> ~95..105.
mean() function
Compute the arithmetic mean of an array of numbers.
sum() function
Sum all elements of an array of numbers.
sigma() function
Compute standard deviation of an array of numbers.
median() function
Compute the median of an array of numbers.
length() function
Return the length of a vector (i.e. sqrt of sum of squares).
from_to() function
Return an array of points from a start to an end, spaced out by a certain distance.
rand() function
Return a random float in [0,1).
randi() function
Return a random 32-bit integer.
srand() function
Seed the random number generator with the given integer, or with current time if none.