Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Manipulating throttle output (function) (http://www.chiefdelphi.com/forums/showthread.php?t=91433)

DSST\neal.ian 10-02-2011 15:31

Manipulating throttle output (function)
 
This isn't a question on how to program or anything, but more of a mathematical question (I put it here because I figured this was more oten visited). My question is this: what is a function/equation I can use to change what the lower bound on the throttle is? I know that it gives outputs from -1 to 1 and to use it I need to negate the value that comes out, since "up" is -1. I figured out a function to manipulate the throttle inputs to get values from 0 to 1, which was (Z+1)/2, of course multiplied times -1 to give the right values. Any thoughts, or questions? Did this make sense at all? Thanks.

DSST\neal.ian 10-02-2011 16:01

Re: Manipulating throttle output (function)
 
To clarify, I want a function in terms of X, Z, an W, where X is the new lower bound, Z is the throttle's raw output (or inverted, it doesn't matter), and W is the new output from X to 1.

Aaron V 10-02-2011 16:23

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.

DSST\neal.ian 10-02-2011 17:31

Re: Manipulating throttle output (function)
 
Sweet! Thanks!

Aaron V 10-02-2011 19:45

Re: Manipulating throttle output (function)
 
Quote:

Originally Posted by DSST\neal.ian (Post 1020105)
Sweet! Thanks!

No Problem :)


All times are GMT -5. The time now is 03:46.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi