#How can I get a float from 0-1 from 3 floats (a value, a min, and a max).

12 messages · Page 1 of 1 (latest)

autumn flax
#

I am trying to create a function that takes in three floats and returns a single float from 0-1.
For example if these were the values passed in:
Value: 22000, Min: 22000, Max: 23250
Then it should return 0, but if these were the values passed in:
Value: 23250, Min: 22000, Max: 23250
it would return 1.
And any value between 22000 and 23250 would return a different number like 0.356 or 0.935, with the returned number being higher the closer to the max value it is.

I can't figure out what equations I could use to achieve this.

heady prismBOT
#

This post has been reserved for your question.

Hey @autumn flax! Please use /close or the Close Post button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

coral pond
#

so inverse lerp?

autumn flax
#

idk what a lerp is

coral pond
#

try googling lerp/inverse lerp/linear interpolation

autumn flax
#

alr

halcyon estuary
#

this is probably what you want

#

get the difference between the value and the min, and compare it to the max difference between min and max to figure out where you are on the scale from min to max

autumn flax
#

this worked:

(value - min) / (max - min)
halcyon estuary
coral pond
#

yeah that's inverse lerp