diff options
| author | Jacob Palecki <[email protected]> | 2020-07-23 00:55:10 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-23 00:55:10 -0700 |
| commit | e798ac56843a8e7b383433c479c802a4fb245a4c (patch) | |
| tree | 66dc866f1de4fb5e2fadaf4d433a48e754446df9 /common/rawaccel.hpp | |
| parent | Merge pull request #1 from JacobPalecki/PowerStyle (diff) | |
| download | rawaccel-e798ac56843a8e7b383433c479c802a4fb245a4c.tar.xz rawaccel-e798ac56843a8e7b383433c479c802a4fb245a4c.zip | |
Fix offset for power mode, add scale factor for power mode
Diffstat (limited to 'common/rawaccel.hpp')
| -rw-r--r-- | common/rawaccel.hpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index a40b85b..52402d5 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -74,7 +74,8 @@ struct accel_function { double b = 0; // the limit for natural and sigmoid modes, - // or the exponent for classic mode + // the exponent for classic mode, + // or the scale factor for power mode double k = 1; vec2d weight = { 1, 1 }; @@ -98,7 +99,7 @@ struct accel_function { break; case mode::sigmoid: accel_val = k / (exp(-b * (speed - m)) + 1); break; - case mode::power: accel_val = pow(speed, b) - 1; + case mode::power: accel_val = b < 1 ? 0 : pow(speed, b*k) - 1; break; default: break; @@ -131,6 +132,7 @@ struct accel_function { if (args.time_min <= 0) error("min time must be positive"); if (args.lim_exp <= 1) { if (args.accel_mode == mode::classic) error("exponent must be greater than 1"); + else if (args.accel_mode == mode::power) error("scale factor must be greater than 1"); else error("limit must be greater than 1"); } |