Quote:
|
Originally Posted by billbo911
I've often wondered how I could linearize a range of values to another range of values, such as 137-235 linearized to 137-254...So the question is, what code would you use to linearly map one range to another?
|
Use the equation for a line,
y = mx + b.
Take the input value
x, multiply it by a factor
m, and add an offset
b to yield the output value
y. The factor can be a floating point value, or to save time you can multiply by an integer and divide by another integer.
To determine the
m and
b constants, use algebra to solve the pair of equations for the known input and output values.