diff options
| -rw-r--r-- | common/accel-logarithm.hpp | 33 | ||||
| -rw-r--r-- | common/common.vcxitems | 1 | ||||
| -rw-r--r-- | common/rawaccel-settings.h | 2 | ||||
| -rw-r--r-- | common/rawaccel.hpp | 3 | ||||
| -rw-r--r-- | grapher/Layouts/LogarithmLayout.cs | 21 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 1 | ||||
| -rw-r--r-- | grapher/Models/Serialized/DriverSettings.cs | 2 | ||||
| -rw-r--r-- | grapher/grapher.csproj | 4 |
8 files changed, 65 insertions, 2 deletions
diff --git a/common/accel-logarithm.hpp b/common/accel-logarithm.hpp new file mode 100644 index 0000000..0dbf433 --- /dev/null +++ b/common/accel-logarithm.hpp @@ -0,0 +1,33 @@ +#pragma once + +#include <math.h> + +#include "accel-base.hpp" + +namespace rawaccel { + + /// <summary> Struct to hold sigmoid (s-shaped) gain implementation. </summary> + struct logarithm_impl { + double rate; + double offset; + double additive_const; + + logarithm_impl (const accel_args& args) : + rate(args.rate), offset (args.offset) { + additive_const = offset * rate; + } + + inline double operator()(double speed) const { + //f(x) = k/(1+e^(-m(c-x))) + double scaled_speed = rate * speed + 1; + double base_speed = speed + offset; + + return (scaled_speed * log(scaled_speed) + additive_const ) / ( rate * base_speed) - 1; + } + + inline double legacy_offset(double speed) const { return operator()(speed); } + }; + + using accel_logarithm = additive_accel<logarithm_impl>; + +} diff --git a/common/common.vcxitems b/common/common.vcxitems index 2913080..fcd3ae8 100644 --- a/common/common.vcxitems +++ b/common/common.vcxitems @@ -17,6 +17,7 @@ <ClInclude Include="$(MSBuildThisFileDirectory)accel-base.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-classic.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-linear.hpp" /> + <ClInclude Include="$(MSBuildThisFileDirectory)accel-logarithm.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-natural.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-naturalgain.hpp" /> <ClInclude Include="$(MSBuildThisFileDirectory)accel-noaccel.hpp" /> diff --git a/common/rawaccel-settings.h b/common/rawaccel-settings.h index 12f136d..8c483eb 100644 --- a/common/rawaccel-settings.h +++ b/common/rawaccel-settings.h @@ -6,7 +6,7 @@ namespace rawaccel { enum class accel_mode { - linear, classic, natural, naturalgain, sigmoidgain, power, noaccel + linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, noaccel }; struct settings { diff --git a/common/rawaccel.hpp b/common/rawaccel.hpp index 08ac322..8819302 100644 --- a/common/rawaccel.hpp +++ b/common/rawaccel.hpp @@ -8,6 +8,7 @@ #include "accel-linear.hpp" #include "accel-classic.hpp" +#include "accel-logarithm.hpp" #include "accel-natural.hpp" #include "accel-naturalgain.hpp" #include "accel-power.hpp" @@ -84,6 +85,7 @@ namespace rawaccel { case accel_mode::naturalgain: return vis(var.u.naturalgain); case accel_mode::sigmoidgain: return vis(var.u.sigmoidgain); case accel_mode::power: return vis(var.u.power); + case accel_mode::logarithm: return vis(var.u.logarithm); default: return vis(var.u.noaccel); } } @@ -98,6 +100,7 @@ namespace rawaccel { accel_naturalgain naturalgain; accel_sigmoidgain sigmoidgain; accel_power power; + accel_logarithm logarithm; accel_noaccel noaccel = {}; } u = {}; diff --git a/grapher/Layouts/LogarithmLayout.cs b/grapher/Layouts/LogarithmLayout.cs new file mode 100644 index 0000000..5b25d60 --- /dev/null +++ b/grapher/Layouts/LogarithmLayout.cs @@ -0,0 +1,21 @@ +using grapher.Models.Serialized; + +namespace grapher.Layouts +{ + public class LogarithmLayout : LayoutBase + { + public LogarithmLayout () + : base() + { + Name = "Logarithm"; + Index = (int)AccelMode.logarithm; + + AccelLayout = new OptionLayout(true, Scale); + CapLayout = new OptionLayout(true, Cap); + WeightLayout = new OptionLayout(true, Weight); + OffsetLayout = new OptionLayout(true, Offset); + LimExpLayout = new OptionLayout(false, string.Empty); + MidpointLayout = new OptionLayout(false, string.Empty); + } + } +} diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 14c2019..917ac5c 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -18,6 +18,7 @@ namespace grapher new ClassicLayout(), new NaturalLayout(), new PowerLayout(), + new LogarithmLayout(), new NaturalGainLayout(), new SigmoidGainLayout(), new OffLayout() diff --git a/grapher/Models/Serialized/DriverSettings.cs b/grapher/Models/Serialized/DriverSettings.cs index d7c9444..d42187c 100644 --- a/grapher/Models/Serialized/DriverSettings.cs +++ b/grapher/Models/Serialized/DriverSettings.cs @@ -8,7 +8,7 @@ namespace grapher.Models.Serialized public enum AccelMode { - linear, classic, natural, naturalgain, sigmoidgain, power, noaccel + linear, classic, natural, naturalgain, sigmoidgain, power, logarithm, noaccel } #endregion Enumerations diff --git a/grapher/grapher.csproj b/grapher/grapher.csproj index 74e2959..8f5eeda 100644 --- a/grapher/grapher.csproj +++ b/grapher/grapher.csproj @@ -54,6 +54,7 @@ </ItemGroup> <ItemGroup> <Compile Include="Constants\Constants.cs" /> + <Compile Include="Layouts\LogarithmLayout.cs" /> <Compile Include="Layouts\NaturalGainLayout.cs" /> <Compile Include="Layouts\SigmoidGainLayout.cs" /> <Compile Include="Models\AccelGUIFactory.cs" /> @@ -131,5 +132,8 @@ <Name>wrapper</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <Folder Include="ReadMe\" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> </Project>
\ No newline at end of file |