change values by a percentage factor

118 Views Asked by At

I have a problem in that i have a camera with a zoom range values between 1,000 and 30,000. The problem is i am accessing these values through a slider bar with values starting 250 to 750.

How can i creat such an algorithm so that 250 on the slider = 1000, yet 750 also = 30,000.

Something like, slider value(300) * X = the zoom range.

The difference of 20,000 possible values down to 500 means each slider increment should increment the the camera zoom by 40.

1

There are 1 best solutions below

0
On BEST ANSWER

There are 29,001 different values in the zoom range, not 20,000 (unless your range starts at 10,000 instead of 1,000?) You're looking for the equation of a line that connects the points $(250, 1000)$ and $(750, 30,000)$ which is $$ z = 58s - 13500 $$

where $s$ is your slider value and $z$ is the value in your zoom range.