diff options
| author | a1xd <[email protected]> | 2020-08-31 19:41:21 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-08-31 19:41:21 -0400 |
| commit | 9010cc593af419dd824dba0ade6a2022aea6143f (patch) | |
| tree | 90a82ee14dbb112621657efbd2523ed35f59d154 /common/accel-sigmoidgain.hpp | |
| parent | clean up wrapper, minimize heap alloc (diff) | |
| download | rawaccel-9010cc593af419dd824dba0ade6a2022aea6143f.tar.xz rawaccel-9010cc593af419dd824dba0ade6a2022aea6143f.zip | |
add independent xy accel to driver
other changes:
modifier_args type name is now settings,
which is now the type passed in driver ioctl
remove most settings/args verification from driver,
plan to let gui handle most of it
add another accel arg, rate, which is used to set
the 'accel' parameter of types which call exp (nat/sig),
might want to cap it
add (update) serializable DriverSettings (ModifierArgs) class to
gui and static methods for interop
remove properties from ManagedAccel, its now just a black box
for accessing modifier methods
add exception handling in wrapper_io to throw proper managed types
change SettingsManager::Startup to make a new settings file
if an error occurs during deserialization
change structure of accel types; how offset and weight are applied
now depend on additivity of types
remove tagged_union and add a handrolled variant/visit impl
AccelGui::UpdateActiveValueLabels currently broken for caps
and a few other args
remove gui default layout and initial natural accel setup
cli not updated
Diffstat (limited to 'common/accel-sigmoidgain.hpp')
| -rw-r--r-- | common/accel-sigmoidgain.hpp | 32 |
1 files changed, 14 insertions, 18 deletions
diff --git a/common/accel-sigmoidgain.hpp b/common/accel-sigmoidgain.hpp index 0a2e54d..99bb146 100644 --- a/common/accel-sigmoidgain.hpp +++ b/common/accel-sigmoidgain.hpp @@ -7,31 +7,27 @@ namespace rawaccel { /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary> - struct accel_sigmoidgain : accel_base { - double limit = 1; - double midpoint = 0; - double additive_constant = 0; - double integration_constant = 0; - - accel_sigmoidgain(const accel_args& args) : accel_base(args) { - verify(args); - - limit = args.limit - 1; - midpoint = args.midpoint; - additive_constant = exp(speed_coeff*midpoint); + struct sigmoidgain_impl { + double rate; + double limit; + double additive_constant; + double integration_constant; + + sigmoidgain_impl(const accel_args& args) : + rate(args.rate), limit(args.limit - 1) + { + additive_constant = exp(rate * args.midpoint); integration_constant = log(1 + additive_constant); } - inline double accelerate(double speed) const { + inline double operator()(double speed) const { //f(x) = k/(1+e^(-m(c-x))) - double scaled_speed = speed_coeff * speed; + double scaled_speed = rate * speed; return limit * ((log(additive_constant+exp(scaled_speed)) - integration_constant)/scaled_speed); } - void verify(const accel_args& args) const { - if (args.limit <= 1) bad_arg("exponent must be greater than 1"); - if (args.midpoint < 0) bad_arg("midpoint must not be negative"); - } }; + using accel_sigmoidgain = additive_accel<sigmoidgain_impl>; + } |