From 4f4e86ce4f87987fb2376dc7fda5cec8b89bbe31 Mon Sep 17 00:00:00 2001 From: lisyarus Date: Sun, 23 Feb 2025 13:56:13 +0300 Subject: [PATCH] Add math::inverse_smoothstep --- libs/math/include/psemek/math/math.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libs/math/include/psemek/math/math.hpp b/libs/math/include/psemek/math/math.hpp index d29f14f9..f3e598ea 100644 --- a/libs/math/include/psemek/math/math.hpp +++ b/libs/math/include/psemek/math/math.hpp @@ -225,4 +225,10 @@ namespace psemek::math return x * x * x * (10 - x * (15 - 6 * x)); } + template + T inverse_smoothstep(T x) + { + return T{1} / T{2} - std::sin(std::asin(T{1} - T{2} * x) / T{3}); + } + }