Add 3-argument smoothstep and smootherstep
All checks were successful
Run tests / Run tests (push) Successful in 8m42s

This commit is contained in:
Nikita Lisitsa 2026-09-03 12:14:54 +03:00
parent 2db6c32310
commit 880bbba491

View file

@ -230,6 +230,12 @@ namespace psemek::math
return x * x * (T{3} - T{2} * x); return x * x * (T{3} - T{2} * x);
} }
template <typename T>
T smoothstep(T edge0, T edge1, T x)
{
return smoothstep(clamp((x - edge0) / (edge1 - edge0), T{0}, T{1}));
}
template <typename T> template <typename T>
T smootherstep(T x) T smootherstep(T x)
{ {
@ -237,6 +243,12 @@ namespace psemek::math
return x * x2 * (T{10} - x * T{15} + x2 * T{6}); return x * x2 * (T{10} - x * T{15} + x2 * T{6});
} }
template <typename T>
T smootherstep(T edge0, T edge1, T x)
{
return smootherstep(clamp((x - edge0) / (edge1 - edge0), T{0}, T{1}));
}
template <typename T> template <typename T>
T inverse_smoothstep(T x) T inverse_smoothstep(T x)
{ {