Hello! I am trying to convert a range of number into a simple curve on a different scale.
But my programming, and particularly the maths portions of it, is quite rusty.
So I have a range from 0 to 500.
I wish to convert it to a range from 0 to 10000 in a curve.
In effect, my goal is to have the result be as close to 1:1 as possible when dealing with lower numbers, and proportionally curve up towards 10000 where towards the end we are having a rate of 20:1.
What is the simplest way of going about doing this?
What the function does is totally up to you. If you can curve fit your data to a power function or exponential function, then you can simply use those fitted values to calculate your new value. If you can't you do do some sort of lookup table or break it up into different functions depending if the input is small, medium or large.
The scaling is from 1 on the low end to 20 on the high end. In order to be a simple ratio (as you had requested) that has to be from zero to something (19 in this case) then offset (add one) to get the ratio into the desired range.
Ratio = (OldValue * (20.0 - 1.0) / 500.0 + 1.0);
Subtract one so a simple scaling can be applied. Apply the scaling. Add one (put the one back). That value is the ratio.
Then save the points in your code and do piecewise linear interpolation for any input.
(ie if you have an input of 225, you'd calculate a value half-way between the saved values for 200 and 250.)
You can do non-linear interpolation as well, but that gets more complicated.
This way you can easily adjust the curve any way you want, without having to figure out the exact mathematical equation that fits the points...