5#ifndef SAPPHIRE_MATHS_LERP_GUARD
6#define SAPPHIRE_MATHS_LERP_GUARD
45 return (1.0f - _alpha) * _start + _alpha * _end;
62 T
Lerp(
const T& _start,
const T& _end,
float _alpha)
noexcept
64 SA_WARN(_alpha >= 0.0f && _alpha <= 1.0f, SA.Maths, (L
"Alpha[%1] clamped to range [0, 1]! Use LerpUnclamped if intended instead.", _alpha));
66 return LerpUnclamped(_start, _end, std::clamp(_alpha, 0.0f, 1.0f));
91 using TScalar =
typename T::Type;
92 TScalar dot = T::Dot(_start, _end);
93 TScalar endSign = 1.0f;
103 if (Maths::Equals1(dot))
116 TScalar sin =
Sin(angle);
119 TScalar sinRatio =
Sin(angleStep) / sin;
121 TScalar s0 =
Cos(angleStep) - dot * sinRatio;
123 return s0 * _start + sinRatio * _end * endSign;
139 template <
typename T>
140 T
SLerp(
const T& _start,
const T& _end,
float _alpha)
noexcept
142 SA_WARN(_alpha >= 0.0f && _alpha <= 1.0f, SA.Maths, (L
"Alpha[%1] clamped to range [0, 1]! Use LerpUnclamped if intended instead.", _alpha));
144 return SLerpUnclamped(_start, _end, std::clamp(_alpha, 0.0f, 1.0f));
Cosinus method implementation.
constexpr T Cos(Rad< T > _in) noexcept
Compute the cosine of the input.
Definition Cos.hpp:32
constexpr Rad< T > ACos(T _in) noexcept
Compute the arc-cosine of the input.
Definition Cos.hpp:46
Maths module Debug compatibility definition.
T LerpUnclamped(const T &_start, const T &_end, float _alpha) noexcept
Unclamped Lerp from _start to _end at _alpha.
Definition Lerp.hpp:43
T SLerp(const T &_start, const T &_end, float _alpha) noexcept
Clamped SLerp from _start to _end at _alpha.
Definition Lerp.hpp:140
T Lerp(const T &_start, const T &_end, float _alpha) noexcept
Clamped Lerp from _start to _end at _time.
Definition Lerp.hpp:62
T SLerpUnclamped(const T &_start, const T &_end, float _alpha) noexcept
Unclamped SLerp from _start to _end at _alpha.
Definition Lerp.hpp:84
Sinus method implementation.
constexpr T Sin(Rad< T > _in) noexcept
Compute the sine of the input.
Definition Sin.hpp:32
Maths Radian type.
Definition Radian.hpp:36