I very frequently need to use a simple lerp function and am constantly rewriting it. It would be very useful if this was built into the math library with math.lerp
function math.lerp(A: number, B: number, D: number): number
return A + ((B - A) * D)
end
You could say the same about math.min, math.clamp, math.max, and many other math operations. It isnât about how easy it is to write, itâs about using basic math operations without needing custom functions.
We use so many useful functions that arenât very complicated. A key principle of scripting is DRY, and I highly believe that, as you said, built-in functions for basic math operations shouldnât be considered useless.
Look at how many people thought it already existed by googling
Math, min max and clamp are useful because making separated functions for them is more difficult than writing 10 letters. Like for min and max you need to loop through the table and for clamp you need to use mon and max so clearly mot as super easy as lerping. Lerping is also less used so it further adds on to the uselessness of math.lerp.
just because some people donât use it often doesnât make it useless, i use lerp functions all the time, way more than probably any math library call besides sin/cos; math.rad and math.deg can also be written in like 7 chars but itâs still a useful function
I still find it useless. I barely see people ending up using lerp. I do use it sometimes but itâs not like I want a dedicated function for it. I actually end up using sin/cos, rad/deg more! Maybe because I am focused on CFrame manipulation more?? Or something?
Also lerping would only be like useful to just lerp some number!
Also you may wonder why I am so against it? Well because the roblox platform is already so limiting that I think they should focus on adding more bigger stuff than adding this extension.
Youâll have more luck creating an RFC (Request for comments) on the Luau RFC repository. This will get you directly in contact with those in charge (The Luau team).
Maybe I am wrong but the simplest method I see is:
local function Min(...)
local minNum = math.huge
for _,num in {...} do
if num < minNum then minNum = num end
end
return minNum
end
I assume you would use it like:
if x < y then
print("x is smaller")
end
But if we talk about the use of math.min then itâs not a mere operation to be done in â10 charactersâ.
In my case and people I see around, it is. Maybe for a group of people it is, but for me it isnât.
It could slow it a bit? I could be wrong about it but just saying that they should focus on fixing the bajillion bugs with studio and the website they have rather than adding minuscule QOL features.
Your method is correct for multiple numbers but I was thinking of a traditional two-number input. Apologies for the misunderstanding.
I donât believe it would, especially since itâs one function. Even with the addition of all the current Luau libraries, the performance of code has not been affected negatively.
There are multiple teams of engineers within Roblox. The team that works on the studio app and the team that works on the website is not the team that works on the Luau codebase. Thatâs why I believe adding this function shouldnât redirect focus of Studio and website matters.
Yeah itâs fine. I wanted to replicate the flexibility of the function. For a traditional two or three number system using â<â and â>â would be more than enough.
I meant as in for the engineers. Would slow down the progress on up-coming features by a bit.
Ohhh, that makes a lot of sense! I didnât really knew that. Sorry for that. I guess you win on this then. I thought there was only a single engineering team, seeing how slow roblox is with most stuff.
, but Iâve written the exact same expression so many times that Iâve completely memorised it. I really dislike having to write âutilityâ functions that have nothing to do with the rest of my code, I agree this should be in the language.
My reason for wanting this isnât to cut down on the utility functions I need to write but rather to abstract away any potential optimisations over the engine. I use lerping a lot in my code and, as such, need the most performant solution. Not only would moving the function over to the C-side likely result in natural optimisations but it would also allow the engine developers, who are likely more experienced in optimisation than many developers, to implement those optimisations for us.