Class: MathUtils
Defined in: utils/MathUtils.ts:2
Utility methods for numeric clamping and alignment
Constructors
Constructor
new MathUtils():
MathUtils
Returns
MathUtils
Methods
align()
staticalign(n,m):number
Defined in: utils/MathUtils.ts:26
Aligns a positive number n to the next multiple of m
If n is already a multiple of m, returns n.
Otherwise, returns the smallest multiple of m that is greater than n.
Parameters
n
number
The non-negative number to align
m
number
The strictly positive multiple to align to
Returns
number
The aligned number
Throws
Error if n is negative, or if m is not strictly positive
clamp()
staticclamp(value,min,max):number
Defined in: utils/MathUtils.ts:11
Clamps a value to the range [min, max]
Parameters
value
number
The value to clamp
min
number
Lower bound
max
number
Upper bound
Returns
number
The clamped value