SA_Maths
Sapphire Suite's C++ Maths Library
Loading...
Searching...
No Matches
Functions
Lerp.hpp File Reference

Lerp algorithms implementation. More...

#include <algorithm>
#include <SA/Maths/Debug.hpp>
#include <SA/Maths/Algorithms/Cos.hpp>
#include <SA/Maths/Algorithms/Sin.hpp>

Go to the source code of this file.

Functions

template<typename T >
T SA::Maths::LerpUnclamped (const T &_start, const T &_end, float _alpha) noexcept
  Unclamped Lerp from _start to _end at _alpha.
 
template<typename T >
T SA::Maths::Lerp (const T &_start, const T &_end, float _alpha) noexcept
  Clamped Lerp from _start to _end at _time.
 
template<typename T >
T SA::Maths::SLerpUnclamped (const T &_start, const T &_end, float _alpha) noexcept
  Unclamped SLerp from _start to _end at _alpha.
 
template<typename T >
T SA::Maths::SLerp (const T &_start, const T &_end, float _alpha) noexcept
  Clamped SLerp from _start to _end at _alpha.
 

Detailed Description

Lerp algorithms implementation.

Function Documentation

◆ Lerp()

template<typename T >
T SA::Maths::Lerp ( const T & _start,
const T & _end,
float _alpha )
noexcept

Clamped Lerp from _start to _end at _time.

Reference: https://en.wikipedia.org/wiki/Linear_interpolation

Template Parameters
TInput type.
Parameters
[in]_startStarting point of the lerp.
[in]_endEnding point of the lerp.
[in]_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

◆ LerpUnclamped()

template<typename T >
T SA::Maths::LerpUnclamped ( const T & _start,
const T & _end,
float _alpha )
noexcept

Unclamped Lerp from _start to _end at _alpha.

Reference: https://en.wikipedia.org/wiki/Linear_interpolation

Template Parameters
TInput type.
Parameters
[in]_startStarting point of the lerp.
[in]_endEnding point of the lerp.
[in]_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

◆ SLerp()

template<typename T >
T SA::Maths::SLerp ( const T & _start,
const T & _end,
float _alpha )
noexcept

Clamped SLerp from _start to _end at _alpha.

Reference: https://en.wikipedia.org/wiki/Slerp

Template Parameters
TInput type.
Parameters
[in]_startStarting point of the lerp.
[in]_endEnding point of the lerp.
[in]_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

◆ SLerpUnclamped()

template<typename T >
T SA::Maths::SLerpUnclamped ( const T & _start,
const T & _end,
float _alpha )
noexcept

Unclamped SLerp from _start to _end at _alpha.

Reference: https://en.wikipedia.org/wiki/Slerp

Template Parameters
TInput type.
Parameters
[in]_startStarting point of the lerp.
[in]_endEnding point of the lerp.
[in]_alphaAlpha of the lerp.
Returns
interpolation between _start and _end. return _start when _alpha == 0.0f and _end when _alpha == 1.0f.

Reference: https://en.wikipedia.org/wiki/Slerp Formula: (Sin((1.0f - _alpha) * angle) * _start) / sin + (sinStep * _end) / sin.