12export import :mappings;
14#define FLOAT_TOLERANCE 0.0001
24std::optional<float>
find_root(std::function<
float(
float)> fun,
float x0,
float x1) {
25 static constexpr int N_MAX = 1000;
38 float x = (x0 + x1) / 2;
53 LOG::print{ERROR}(
"FAILED to find root");
60 using sptr = std::shared_ptr<interpolator_base>;
71 return (1 - t) * x0 + t * x1;
81 return (1 - s) * x0 + s * x1;
85 return (fun(t) - fun(0)) / (fun(1) - fun(0));
102 c0.t = std::clamp(c0.t, 0.0f, 1.0f);
103 c1.t = std::clamp(c1.t, 0.0f, 1.0f);
107 Bs = 3 * (-2 * c0.t + c1.t);
109 Cs = (3 * c0.t - 3 * c1.t + 1);
119 if (s_opt.has_value()) {
125 return x0 + (s * 3 * (c0.x - x0)
126 + s * s * 3 * (x0 - 2 * c0.x + (x1 + c1.x))
127 + s * s * s * (-x0 + 3 * c0.x - 3 * (x1 + c1.x) + x1));
bezier(control_point c0_, control_point c1_)
float_type interpolate(float_type x0, float_type x1, float_type t) const override
float_type interpolate(float_type x0, float_type x1, float_type t) const override
easing(function_type fun)
cydui::easing::function_type function_type
float_type interpolate(float_type x0, float_type x1, float_type t) const override
std::shared_ptr< interpolator_base > sptr
virtual ~interpolator_base()=default
virtual float_type interpolate(float_type x0, float_type x1, float_type t) const =0
std::optional< float > find_root(std::function< float(float)> fun, float x0, float x1)
bool fuzzy_eq(const float a, const float b)
std::function< float_type(const float_type &)> function_type