As a Roblox developer, it is currently too hard to …
Perform semi-complex math / operations using built-in library functions.
If Roblox is able to address this issue, it would improve my development experience because …
Not having to implement boiler-plate libraries for commonly needed functionality.
I believe the addition of these functions will have great productivity and performance impacts:
To math:
math.e = 2.7182818284590452353602874713526624977572470936999595749669676277
math.maxint = 2^53-1
math.mindecimal = math.ldexp(1, -1022) -- 1073 on x86
math.lerp(a, b, alpha) = a + (b - a) * alpha
math.map(x, aMin, aMax, bMin, bMax) = bMin + (x - aMin) * (bMax - bMin) / (aMax - aMin)
math.log2(x) = make use of FYL2X instruction on x86
math.isinf(x) = x == math.huge or x == -math.huge
math.isnan(x) = x ~= x
math.isfinite(x) = x ~= math.huge and x ~= -math.huge and x == x
math.isint(x) = x ~= math.huge and x ~= -math.huge and x == x and x == math.floor(x)
-- Normalize a value represented in radians to 0,2pi
math.radnorm(a) =
if a < 0 then
a += math.ceil(-a / RADIANS_360) * RADIANS_360
end
return a % RADIANS_360
-- Compute the difference between both degree values, supporting going around the circle
math.raddelta(a, b) =
local diff: number = math.radnorm(b) - math.radnorm(a)
if diff > RADIANS_180 then
diff -= RADIANS_360
elseif diff < -RADIANS_180 then
diff += RADIANS_360
end
return diff
-- Same functionality but with degrees instead of radians
math.degnorm(a) = ...
math.degdelta(a, b) = ...
To Random:
Normal number generation with (mu, sigma) parameters
Uniform Vector2, Vector3
Re-seeding
Re-wind (reverse)
To Vector2/Vector3:
More operators such as Pow, Abs, Sign, Clamp, Max, Min, etc...
Checks: IsFinite, IsNaN, IsInt, IsInf
Conversion To/From Color3
Domain mapping, i.e. map x from (aMin, aMax) -> (bMin, bMax)
MagnitudeSq or DistSq
Color3:
Conversion To/From Vector3
HSL support
Function to clamp within (0,1)
Color distance calculation
Grayscale value, i.e. color.R * 0.299 + color.G * 0.587 + color.B * 0.114
Convert to/from array
NumberSequence / ColorSequence:
Eval(x) = ...
Curve fitting toolkit:
ExpFit in 1, 2, 3 dimensions
PolyFit in 1, 2, 3 dimensions
SplineFit in 1, 2, 3 dimensions
2d / 3d geometry primitives:
Intersections
Inside/Outside test
Matrix N x M class
Crypto/Hashing library:
CRC32, SHA1, MD5, SHA2, SHA3, etc...
Base64
Secure PRNG.
String:
isascii
Levenshtein distance
JSON Pretty printing
Complex date formatting/parsing
Complex number formatting/parsing
Proper timezone support
Ability to query the number of processing cores for optimal parallel batching
I let some additional things slip in that aren’t strictly math related, but the point is pretty clear.
Some of these are trivial and also exist in newer Lua versions.
This is not an exhaustive list, but looking for feedback here.
ALL of these things CAN be implemented in pure Lua, but suffer for significant performance penalties and are painful to carry around - they make developing more difficult. These primitives should be accessible to everyone, not just those of us who have curated/tested libraries of our own with these basic functions.