I have a min and max position of an object and I want to represent an arbitrary point between them as a float between 0.0 and 1.0. This feels relatively basic math, but I can’t quite figure out what I need to do with this. Is there a special name for this sort of thing? Also, are there any built-in methods that would be useful for this?

  • Toine
    link
    fedilink
    arrow-up
    2
    ·
    1 year ago

    OP might also be interested in the reverse operation. If s is your number from 0 to 1, the corresponding position in the “real” space is min + s * (max-min), which can also be written as (1-s)min + smax . This is sometimes called a linear interpolation, or a weighted average. Note that you can also use the same formulas with s smaller than zero and larger than one, thus performing linear extrapolation. Finally, these same formulas apply in higher dimensions, just think of min and max as the coordinates of two vectors, and appy these formulas for each coordinate, and you get linear interpolation between your two vectors.