Add geom::smoothstep & smootherstep
This commit is contained in:
parent
3ca9c8b16e
commit
48801a69da
2 changed files with 15 additions and 1 deletions
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/geom/math.hpp>
|
||||
|
||||
#include <psemek/util/assert.hpp>
|
||||
|
||||
namespace psemek::geom
|
||||
|
|
@ -26,7 +28,7 @@ namespace psemek::geom
|
|||
case easing_type::linear: return t;
|
||||
case easing_type::quadratic_in: return t * t;
|
||||
case easing_type::quadratic_out: return t * (2 - t);
|
||||
case easing_type::cubic: return t * t * (3 - 2 * t);
|
||||
case easing_type::cubic: return smoothstep(t);
|
||||
default: assert(false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -193,4 +193,16 @@ namespace psemek::geom
|
|||
return false;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T smoothstep(T x)
|
||||
{
|
||||
return x * x * (3 - 2 * x);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T smootherstep(T x)
|
||||
{
|
||||
return x * x * x * (10 - x * (15 - 6 * x));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue