-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GDScript Built-in: add inverse_lerp & range_lerp #10225
Conversation
I don't like the |
Edit: With |
Also, I figured out that Unity has an InverseLerp function. Maybe you could add this function too ? Also that would mean that you could implement range_lerp with something like:
(Don't copy as is, it might not work) |
I don't find this function useful, and I don't agree that it should be in the core for reasons I've reiterated several times in #10195. |
@groud I'm not sure what InverseLerp would return if,
|
I agree with @vnen that remap is a much better name for it, or even rangemap which is the name I tend to use. |
@Noshyaar min should not be equal to max. Just raise an error if so with ERR_COND...(i don't remember the exact name) and return 0 or something like that. |
@groud Well, if they are equal, you get a division by zero, but since you use floating-point numbers, you get either +Infinity or -Infinity, no? (on NaN, in case you try |
My bad, you're right: |
Just a note, working with Unity for years and never used InverseLerp, even though I know it exists. Must be the habit of doing things explicitely though. If they are added, I think |
Could you rename the parameters of |
As discussed on IRC (from 0:14), since we provide It's also a common operation found in other math libraries (Unity, Arduino). |
WIP
It's useful to me and some other people.
Fixes #10195