Num class provides static helper functions for basic numeric operations.
Average a group of numeric arrays
a Group or an Iterable
a Pt of averages
Different from Num.clamp
in that the value out-of-bound will be "looped back" to the other end.
value to bound
min value
max value
boundValue(361, 0, 360)
will return 1
Clamp values between min and max.
value to clamp
min value
max value
Given a value between 0 to 1, returns a value that cycles between 0 -> 1 -> 0 using the provided shaping method.
a value between 0 to 1
a shaping method. Default to Shaping.sineInOut
.
a value between 0 to 1
Check if two numbers are equal or almost equal within a threshold.
number a
number b
threshold value that specifies the minimum difference within which the two numbers are considered equal
Calculate linear interpolation between 2 values.
start value
end value
an interpolation value, usually between 0 to 1
Map a value from one range to another.
a value in the first range
a remapped value in the second range
Normalize a value within a range.
the value to normalize
range value 1
range value 1
Return a random number between 0 and 1 from a seed, if the seed is not defined it uses Math.random
a number between 0 and 1
Get a random Pt within the range defined by either 1 or 2 Pt
the range if only one Pt is used, or the start of the range if two Pt were used
optional Pt to define the end of the range
Get a random number within a range.
range value 1
range value 2
Seed the pseudorandom generator.
seed string
Sum a group of numeric arrays.
a Group or an Iterable
a Pt of the dimensional sums
Check if a value is within two other values
value to check
first bounding value
second bounding value