diff --git a/libs/math/include/psemek/math/math.hpp b/libs/math/include/psemek/math/math.hpp index a84b7871..8bcc8825 100644 --- a/libs/math/include/psemek/math/math.hpp +++ b/libs/math/include/psemek/math/math.hpp @@ -224,12 +224,24 @@ namespace psemek::math return false; } + template + H step(T edge0, T edge1, H x) + { + return clamp((x - edge0) / (edge1 - edge0), H{0}, H{1}); + } + template T smoothstep(T x) { return x * x * (T{3} - T{2} * x); } + template + H smoothstep(T edge0, T edge1, H x) + { + return smoothstep(clamp((x - edge0) / (edge1 - edge0), H{0}, H{1})); + } + template T smootherstep(T x) { @@ -237,6 +249,12 @@ namespace psemek::math return x * x2 * (T{10} - x * T{15} + x2 * T{6}); } + template + H smootherstep(T edge0, T edge1, H x) + { + return smootherstep(clamp((x - edge0) / (edge1 - edge0), H{0}, H{1})); + } + template T inverse_smoothstep(T x) {