Skip to content

@technobuddha > library > Math

Operations

NameTypeDescription
ceilFunctionReturns the smallest integer greater than or equal to the given number, with optional tolerance and precision adjustments.
CeilOptionsTypeOptions for the ceil function
clampFunctionClamps a number within the inclusive range specified by min and max.
crossProductFunctionCalculates the cross product of vectors OA and OB, where O, A, and B are points in 2D Cartesian space. The result is positive if the sequence OAB makes a counter-clockwise turn, negative for a clockwise turn, and zero if the points are collinear.
floorFunctionReturns the largest integer less than or equal to the given number, with optional tolerance and precision adjustments.
FloorOptionsTypeOptions for the floor function
lerpFunctionPerforms linear interpolation between values a and b. Returns the value between a and b proportional to x (when x is between 0 and 1. When x is outside this range, the return value is a linear extrapolation).
moduloFunctionThe % operator in JavaScript returns the remainder of a / b, but differs from some other languages in that the result will have the same sign as the dividend. For example, -1 % 8 == -1, whereas in some other languages (such as Python) the result would be 7. This function emulates the more correct modulo behavior, which is useful for certain applications such as calculating an offset index in a circular list.
roundFunctionReturns the nearest integer to the given number, with optional precision adjustments.
RoundOptionsTypeOptions for the round function