MathUtils
phi
The golden ratio
Example
print(MathUtils.phi)
1.6180339887499
ga
The golden angle in radians
Example
-- Converted to degrees
print(math.deg(MathUtils.ga))
137.50776405004
isNaN
Checks if a number is a number
Example
print(MathUtils.isNaN(tonumber("NaN")))
print(MathUtils.isNaN(10))
true
false
round
Similar to math.round()
but allows you to decide nearest multiple to round to
Example
print(MathUtils.round(3, 5))
print(MathUtils.round(2, 5))
5
0
ceil
Similar to math.ceil()
but allows you to decide nearest multiple to round up to
Example
print(MathUtils.ceil(3, 5))
print(MathUtils.ceil(2, 5))
5
5
floor
Similar to math.floor()
but allows you to decide nearest multiple to round down to
Example
print(MathUtils.floor(3, 5))
print(MathUtils.floor(2, 5))
0
0
lerp
Interpolates between number
, Vector3
, and CFrame
Example
print(MathUtils.lerp(0, 100, 0.5))
print(MathUtils.lerp(Vector3.new(), Vector3.new(100, 100, 100), 0.5))
print(MathUtils.lerp(CFrame.new(), CFrame.new(100, 100, 100), 0.5).Position)
50
50, 50, 50
50, 50, 50
factors
Returns all factors of a number including 1 and itself
Example
print(MathUtils.factors(21))
1, 3, 7, 21
isPrime
Returns if a number is prime
Example
print(MathUtils.isPrime(7))
print(MathUtils.isPrime(10))
true
false
snap
Returns the nearest number in a list
Example
print(MathUtils.snap(35, {5, 10, 20, 40, 80}))
40