26 constexpr T linear_func(T x) noexcept
32 constexpr T step_func(T x) noexcept
34 return x < T(0.5f) ? T(0.0f) : T(1.0f);
38 inline T smooth_step_func(T x) noexcept
45 return (T(3.0f) - T(2.0f) * x) * std::pow(x, T(2.0f));
49 inline T smoother_step_func(T x) noexcept
56 return std::pow(x, T(3.0f)) * (x * (x * T(6.0f) - T(15.0f)) + T(10.0f));
60 inline T quadratic_in_func(T x) noexcept
62 return std::pow(x, T(2.0f));
66 constexpr T quadratic_out_func(T x) noexcept
68 return -x * (x - T(2.0f));
72 inline T quadratic_in_out_func(T x) noexcept
75 return T(2.0f) * std::pow(x, T(2.0f));
77 return T(1.0f) - T(2.0f) * std::pow(T(1.0f) - x, T(2.0f));
81 inline T cubic_in_func(T x) noexcept
83 return std::pow(x, T(3.0f));
87 inline T cubic_out_func(T x) noexcept
89 return std::pow(x - T(1.0f), T(3.0f)) + T(1.0f);
93 inline T cubic_in_out_func(T x) noexcept
96 return T(4.0f) * std::pow(x, T(3.0f));
98 return T(1.0f) - T(4.0f) * std::pow(T(1.0f) - x, T(3.0f));
102 inline T quartic_in_func(T x) noexcept
104 return std::pow(x, T(4.0f));
108 inline T quartic_out_func(T x) noexcept
110 return T(1.0f) - std::pow(T(1.0f) - x, T(4.0f));
114 inline T quartic_in_out_func(T x) noexcept
117 return 8 * std::pow(x, T(4.0f));
119 return T(1.0f) - T(8.0f) * std::pow(T(1.0f) - x, T(4.0f));
123 inline T quintic_in_func(T x) noexcept
125 return std::pow(x, T(5.0f));
129 inline T quintic_out_func(T x) noexcept
131 return T(1.0f) + std::pow(x - T(1.0f), T(5.0f));
135 inline T quintic_in_out_func(T x) noexcept
138 return T(16.0f) * std::pow(x, T(5.0f));
140 return T(1.0f) - T(16.0f) * std::pow(T(1.0f) - x, T(5.0f));
144 inline T sine_in_func(T x) noexcept
146 return T(1.0f) +
static_cast<T
>(std::sin(std::numbers::pi_v<T> / T(2.0f) * (x - T(1.0f))));
150 inline T sine_out_func(T x) noexcept
152 return static_cast<T
>(std::sin(std::numbers::pi_v<T> / T(2.0f) * x));
156 inline T sine_in_out_func(T x) noexcept
158 return T(0.5f) * (T(1.0f) -
static_cast<T
>(std::cos(x * std::numbers::pi_v<T>)));
162 inline T circular_in_func(T x) noexcept
164 return T(1.0f) - std::sqrt(T(1.0f) - std::pow(x, T(2.0f)));
168 inline T circular_out_func(T x) noexcept
170 return std::sqrt((T(2.0f) - x) * x);
174 inline T circular_in_out_func(T x) noexcept
178 return T(0.5f) * (T(1.0f) - std::sqrt(T(1.0f) - T(4.0f) * std::pow(x, T(2.0f))));
182 return T(0.5f) * (T(1.0f) + std::sqrt(-T(4.0f) * std::pow(x, T(2.0f)) + T(8.0f) * x - T(3.0f)));
187 inline T exponential_in_func(T x) noexcept
189 return x <= T(0.0f) ? T(0.0f) : std::
pow(T(2.0f), T(10.0f) * (x - T(1.0f)));
193 inline T exponential_out_func(T x) noexcept
195 return x >= T(1.0f) ? T(1.0f) : T(1.0f) - std::
pow(T(2.0f), -T(10.0f) * x);
199 inline T exponential_in_out_func(T x) noexcept
203 else if (x < T(0.5f))
204 return T(0.5f) * std::pow(T(2.0f), T(20.0f) * x - T(10.0f));
205 else if (x < T(1.0f))
206 return T(1.0f) - T(0.5f) * std::pow(T(2.0f), T(10.0f) - T(20.0f) * x);
212 inline T elastic_in_func(T x) noexcept
214 return std::pow(T(2.0f), T(10.0f) * (x - T(1.0f)))
215 *
static_cast<T
>(std::sin(T(13.0f) * std::numbers::pi_v<T> / T(2.0f) * x));
219 inline T elastic_out_func(T x) noexcept
222 - std::pow(T(2.0f), -T(10.0f) * x)
223 *
static_cast<T
>(std::sin(T(13.0f) * std::numbers::pi_v<T> / T(2.0f) * (x + T(1.0f))));
227 inline T elastic_in_out_func(T x) noexcept
231 return T(0.5f) * std::pow(T(2.0f), T(10.0f) * (T(2.0f) * x - T(1.0f)))
232 *
static_cast<T
>(std::sin(T(13.0f) * std::numbers::pi_v<T> * x));
237 - T(0.5f) * std::pow(T(2.0f), T(10.0f) * (T(1.0f) - T(2.0f) * x))
238 *
static_cast<T
>(std::sin(T(13.0f) * std::numbers::pi_v<T> * x));
243 inline T back_in_func(T x) noexcept
245 return x * (std::pow(x, T(2.0f)) -
static_cast<T
>(std::sin(std::numbers::pi_v<T> * x)));
249 inline T back_out_func(T x) noexcept
251 const T fInv = T(1.0f) - x;
252 return T(1.0f) - fInv * (fInv * fInv -
static_cast<T
>(std::sin(std::numbers::pi_v<T> * fInv)));
256 inline T back_in_out_func(T x) noexcept
260 const T f2t = T(2.0f) * x;
261 return T(0.5f) * f2t * (f2t * f2t -
static_cast<T
>(std::sin(std::numbers::pi_v<T> * f2t)));
265 const T fInv = T(2.0f) - T(2.0f) * x;
266 return T(1.0f) - T(0.5f) * fInv * (fInv * fInv -
static_cast<T
>(std::sin(std::numbers::pi_v<T> * fInv)));
271 inline T bounce_out_func(T x) noexcept
273 if (x < T(4.0f) / T(11.0f))
275 return (T(121.0f) * std::pow(x, T(2.0f))) / T(16.0f);
277 else if (x < T(8.0f) / T(11.0f))
279 return T(363.0f) / T(40.0f) * std::pow(x, T(2.0f)) - T(99.0f) / T(10.0f) * x + T(17.0f) / T(5.0f);
281 else if (x < T(9.0f) / T(10.0f))
283 return T(4356.0f) / T(361.0f) * std::pow(x, T(2.0f)) - T(35442.0f) / T(1805.0f) * x + T(16061.0f) / T(1805.0f);
287 return T(54.0f) / T(5.0f) * std::pow(x, T(2.0f)) - T(513.0f) / T(25.0f) * x + T(268.0f) / T(25.0f);
292 inline T bounce_in_func(T x) noexcept
294 return T(1.0f) - bounce_out_func<T>(T(1.0f) - x);
298 inline T bounce_in_out_func(T x) noexcept
301 return T(0.5f) * bounce_in_func<T>(T(2.0f) * x);
303 return T(0.5f) * bounce_out_func<T>(T(2.0f) * x - T(1.0f)) + T(0.5f);
constexpr bool epsilon_greater_equal(T left, T right, T eps=std::numeric_limits< T >::epsilon())
Constexpr comparison function for a user defined epsilon values.
constexpr bool epsilon_less_equal(T left, T right, T eps=std::numeric_limits< T >::epsilon())
Constexpr comparison function for a user defined epsilon values.
constexpr double pow(T number, int nPower)
Power function for integer power.