blob: 239bd9d0733601b41d6a650a3e7b530952c188d9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#pragma once
#include <math.h>
#include "accel-base.hpp"
namespace rawaccel {
/// <summary> Struct to hold sigmoid (s-shaped) acceleration implementation. </summary>
struct sigmoid_impl {
double rate;
double limit;
double midpoint;
sigmoid_impl(const accel_args& args) :
rate(args.accel), limit(args.limit - 1), midpoint(args.midpoint)
{}
inline double operator()(double speed) const {
//f(x) = k/(1+e^(-m(x-c)))
return limit / (exp(-rate * (speed - midpoint)) + 1);
}
inline double legacy_offset(double speed) const { return operator()(speed); }
};
using accel_sigmoid = additive_accel<sigmoid_impl>;
}
|