mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-22 06:12:32 -06:00
Merge 59c9e5f61f into f99920247f
This commit is contained in:
commit
b7626b5283
2 changed files with 29 additions and 2 deletions
|
|
@ -261,11 +261,21 @@ void SeedRandom();
|
|||
// Math utils
|
||||
|
||||
template <typename T>
|
||||
inline T Lerp(T a, T b, double t)
|
||||
constexpr inline T Lerp(T a, T b, double t) noexcept
|
||||
{
|
||||
return T(a * (1.0 - t) + b * t);
|
||||
}
|
||||
|
||||
template <typename T, typename F>
|
||||
constexpr inline T Lerp(const T& a, const T& b, double t, const F& easefn) noexcept // Avoid copying large vector types.
|
||||
{
|
||||
static_assert(std::is_invocable_r_v<double, F, double>,
|
||||
"Upp::Lerp: Easing function must take and return a double");
|
||||
|
||||
const double e = easefn(t);
|
||||
return T(a * (1.0 - e) + b * e);
|
||||
}
|
||||
|
||||
inline double sqr (double a) { return a * a; }
|
||||
inline double argsinh (double s) { return log(s + sqrt(s * s + 1)); }
|
||||
inline double argcosh (double c) { ASSERT(c >= 1); return log(c + sqrt(c * c - 1)); }
|
||||
|
|
|
|||
|
|
@ -125,12 +125,29 @@ Random after seeding it with fixed value.&]
|
|||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:Lerp`(T`,T`,double`): [@(0.0.255) template] <[@(0.0.255) typename]
|
||||
T> T [* Lerp](T [*@3 a], T [*@3 b], [@(0.0.255) double] [*@3 t])&]
|
||||
T>&]
|
||||
[s5;:Upp`:`:Lerp`(T`,T`,double`): [@(0.0.255) constexpr] T [* Lerp](T
|
||||
[*@3 a], T [*@3 b], [@(0.0.255) double] [*@3 t])&]
|
||||
[s2; Computes the linear interpolation between [*@3 a] and [*@3 b], if
|
||||
the parameter [*@3 t] is inside `[0,1`] (the linear extrapolation
|
||||
otherwise).&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:Upp`:`:Lerp`(const T`&`,const T`&`,double`,const F`&`): [@(0.0.255) template]
|
||||
<[@(0.0.255) typename] T, [@(0.0.255) typename] F>&]
|
||||
[s5;:Upp`:`:Lerp`(const T`&`,const T`&`,double`,const F`&`): [@(0.0.255) constexpr]
|
||||
T [* Lerp]([@(0.0.255) const] T[@(0.0.255) `&] [*@3 a], [@(0.0.255) const]
|
||||
T[@(0.0.255) `&] [*@3 b], [@(0.0.255) double] [*@3 t], [@(0.0.255) const]
|
||||
F[@(0.0.255) `&] [*@3 easefn])&]
|
||||
[s2; Computes the linear interpolation between [*@3 a] and [*@3 b], if
|
||||
the parameter [*@3 t] is inside `[0,1`] (the linear extrapolation
|
||||
otherwise).[@N Easing function ][*@3 easefn][@N can be used to achieve
|
||||
different effects (bounce, ease`-in, ease`-out, etc.). Easing
|
||||
function must take and return a ][@(0.0.255) double][@N . This overload
|
||||
can also be used with large types (such as vectors and matrices
|
||||
with defined operators).]&]
|
||||
[s3; &]
|
||||
[s4; &]
|
||||
[s5;:ZeroArray`(x`): [* ZeroArray]([*@3 x])&]
|
||||
[s2;%% Fills C array [%-*@3 x] with zeros.&]
|
||||
[s3; &]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue