diff options
| author | Jacob Palecki <[email protected]> | 2020-07-24 16:18:51 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-07-24 16:18:51 -0700 |
| commit | ff1b51138175e56fcc053683a4a7d265194519b0 (patch) | |
| tree | bead4e812c9b9d6a90d34d10fc3a6d64f5c9d37b /common/rawaccel.hpp | |
| parent | Apply k to speed, allow values over 0 (diff) | |
| download | rawaccel-ff1b51138175e56fcc053683a4a7d265194519b0.tar.xz rawaccel-ff1b51138175e56fcc053683a4a7d265194519b0.zip | |
Flip k and b as scale and exponent for power mode
Diffstat (limited to 'common/rawaccel.hpp')
| -rw-r--r-- | common/rawaccel.hpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index 1b4263c..095af76 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -73,9 +73,8 @@ struct accel_function { // accel ramp rate double b = 0; - // the limit for natural and sigmoid modes, - // the exponent for classic mode, - // or the scale factor for power mode + // the limit for natural and sigmoid modes + // or the exponent for classic and power modes double k = 1; vec2d weight = { 1, 1 }; @@ -99,7 +98,7 @@ struct accel_function { break; case mode::sigmoid: accel_val = k / (exp(-b * (speed - m)) + 1); break; - case mode::power: accel_val = (speed_offset > 0 && speed < 1) ? 0 : pow(speed*k, b) - 1; + case mode::power: accel_val = (speed_offset > 0 && speed < 1) ? 0 : pow(speed*b, k) - 1; break; default: break; @@ -132,7 +131,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) { if (args.lim_exp <= 0) error("scale factor must be greater than 0"); } + if (args.accel_mode == mode::power) { if (args.lim_exp <=0 ) error("exponent must be greater than 0"); } else error("limit must be greater than 1"); } |