Add 3-argument step, smoothstep and smootherstep
All checks were successful
Run tests / Run tests (push) Successful in 8m25s
All checks were successful
Run tests / Run tests (push) Successful in 8m25s
This commit is contained in:
parent
2db6c32310
commit
c1c04fd139
1 changed files with 18 additions and 0 deletions
|
|
@ -224,12 +224,24 @@ namespace psemek::math
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename H>
|
||||||
|
H step(T edge0, T edge1, H x)
|
||||||
|
{
|
||||||
|
return clamp((x - edge0) / (edge1 - edge0), H{0}, H{1});
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T smoothstep(T x)
|
T smoothstep(T x)
|
||||||
{
|
{
|
||||||
return x * x * (T{3} - T{2} * x);
|
return x * x * (T{3} - T{2} * x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template <typename T, typename H>
|
||||||
|
H smoothstep(T edge0, T edge1, H x)
|
||||||
|
{
|
||||||
|
return smoothstep(clamp((x - edge0) / (edge1 - edge0), H{0}, H{1}));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T smootherstep(T x)
|
T smootherstep(T x)
|
||||||
{
|
{
|
||||||
|
|
@ -237,6 +249,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, typename H>
|
||||||
|
H smootherstep(T edge0, T edge1, H x)
|
||||||
|
{
|
||||||
|
return smootherstep(clamp((x - edge0) / (edge1 - edge0), H{0}, H{1}));
|
||||||
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
T inverse_smoothstep(T x)
|
T inverse_smoothstep(T x)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue