|
Re: Manipulating throttle output (function)
So as I understand what you're asking: you basically want to scale the range of -1 to 1 to, say, X to 1.
You're totally right in your (Z + 1) / 2 as a start. (The general equation for values not between -1 and 1 is: (Z - oldMinimum) / (oldMaximum - oldMinimum) assuming Z is you value. If you want to know more about why this is, let me know, but I don't think this is your main question). Now what this does is it gives you a value between 0 and 1 (always). Let's call this value P.
Now that you have this, you want to convert it to a new minimum. To get the new equation, you can just rearrange the old one to get: (newMax - newMin) * P + newMin.
So you can combine these things to get a general equation:
(newMax - newMin) * (Z - oldMin) / (oldMax - oldMin) + newMin
Or, you can do them separately if you want.
|