Last active
January 22, 2019 11:01
-
-
Save taikomatsu/f11b078333e40a77d780bed2c5522909 to your computer and use it in GitHub Desktop.
bias & gain for VEX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float bias(float b; float x) { | |
return pow(x, log(b)/log(0.5)); | |
} | |
float gain(float g; float x) { | |
if (x<0.5) | |
return bias(1-g, 2*x)/2; | |
else | |
return 1-bias(1-g, 2-2*x)/2; | |
} | |
// usage example | |
float x = [email protected]; | |
//[email protected] = bias(0.8, x); | |
//[email protected] = bias(0.2, x); | |
//[email protected] = gain(0.8, x); | |
[email protected] = gain(0.3 , x); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment