Interp¶
File: samarium/math/interp.hpp
Clamp a value to a range, map a value from one range to another
-
namespace interp¶
Functions
-
constexpr auto smooth_step(f64 value)¶
Sigmoid-like smoothing.
- Parameters:
value – Input value in the range [0, 1]
-
constexpr auto smoother_step(f64 value)¶
Smooth step but more!
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease(f64 value, f64 factor = 2.0)¶
Smooth a value with arbitrary smoothing.
https://www.desmos.com/calculator/zeslvu9rap
- Parameters:
value – Input value in the range [0, 1]
factor – Strength of smoothing: 0 is linear, higher values are smoother, lower values are inverse smoothing
-
inline auto ease2(f64 value, f64 factor = 2.0)¶
Smooth a value with arbitrary smoothing. Sharper endpoints than ease()
https://gist.github.com/Bleuje/0917441d809d5eccf4ddcfc6a5b787d9 https://www.desmos.com/calculator/zeslvu9rap
- Parameters:
value – Input value in the range [0, 1]
factor – Strength of smoothing: 0 is linear, higher values are smoother, lower values are inverse smoothing
-
inline auto ease_in_sine(f64 value)¶
Ease In Sine.
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease_out_sine(f64 value)¶
Ease Out Sine.
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease_sine(f64 value)¶
Ease In Out Sine.
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease_in_quad(f64 value)¶
Ease In Quad.
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease_out_quad(f64 value)¶
Ease Out Quad.
- Parameters:
value – Input value in the range [0, 1]
-
inline auto ease_quad(f64 x)¶
Ease In Out Quad.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_cubic(f64 x)¶
Ease In Cubic.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_cubic(f64 x)¶
Ease Out Cubic.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_cubic(f64 x)¶
Ease In Out Cubic.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_quart(f64 x)¶
Ease In Quart.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_quart(f64 x)¶
Ease Out Quart.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_quart(f64 x)¶
Ease In Out Quart.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_quint(f64 x)¶
Ease In Quint.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_quint(f64 x)¶
Ease Out Quint.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_quint(f64 x)¶
Ease In Out Quint.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_expo(f64 x)¶
Ease In Expo.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_expo(f64 x)¶
Ease Out Expo.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_expo(f64 x)¶
Ease In Out Expo.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_circ(f64 x)¶
Ease In Circ.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_circ(f64 x)¶
Ease Out Circ.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_circ(f64 x)¶
Ease In Out Circ.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_back(f64 x)¶
Ease Out Back.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_out_back(f64 x)¶
Ease Out Back.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_back(f64 x)¶
Ease In Out Back.
- Parameters:
x – Input value in the range [0, 1]
-
inline auto ease_in_elastic(f64 x)¶
Ease In Elastic.
- Parameters:
x – Input value in the range [0, 1]
-
constexpr auto ease_out_elastic(f64 value)¶
Ease Out Elastic.
- Parameters:
value – Input value in the range [0, 1] From https://easings.net/#easeOutElastic
-
inline auto ease_elastic(f64 x)¶
Ease In Out Elastic.
- Parameters:
x – Input value in the range [0, 1]
-
template<typename T>
constexpr auto in_range(T value, Extents<T> range_)¶ Check if a value is within some Extents.
- Parameters:
value – Input value
range_ – Input range
-
template<typename T>
constexpr auto clamp(T value, Extents<T> range_) noexcept¶ Ensure a value is within some Extents.
- Parameters:
value –
range_ –
-
template<typename T>
constexpr auto lerp(f64 factor, Extents<T> range_)¶ Linearly interpolate a factor in a range.
- Parameters:
factor –
range_ –
-
template<typename T>
constexpr auto clamped_lerp(f64 factor, Extents<T> range_)¶ Lerp, but clamp the factor in [0, 1].
- Parameters:
factor –
range_ –
-
constexpr auto lerp_rgb(f64 factor, Color from, Color to)¶
Lerp between the RGBA values of 2 Colors.
- Parameters:
factor –
from –
to –
-
constexpr auto lerp_rotate(Vec2 from, Vec2 to, Vec2 center, f64 factor)¶
Lerp between 2 vectors by rotating around a center.
- Parameters:
from –
to –
center –
factor –
-
constexpr auto clamped_lerp_rotate(Vec2 from, Vec2 to, Vec2 center, f64 factor)¶
Clamped Lerp between 2 vectors by rotating around a center.
- Parameters:
from –
to –
center –
factor –
-
template<typename T>
constexpr auto lerp_inverse(T value, Extents<T> range_)¶ Find the factor which lerps the value in the range.
- Parameters:
value –
range_ –
-
template<typename T, typename Output = T>
constexpr auto map_range(T value, Extents<T> from, Extents<Output> to)¶ Map a value from an input range to an output range.
- Template Parameters:
T – Type of value
Output – Cast the result to Output
- Parameters:
value –
from –
to –
-
template<typename T, typename Output = T>
constexpr auto map_range_clamp(T value, Extents<T> from, Extents<Output> to)¶ Map range, but clamp the value to the output range.
- Template Parameters:
T – Type of value
Output – Cast the result to Output
- Parameters:
value –
from –
to –
-
template<typename T, typename Output = T>
constexpr auto make_mapper(Extents<T> from, Extents<Output> to)¶ Make a lambda which maps its argument from and to fixed ranges.
- Template Parameters:
T – Type of value
Output – Cast the result to Output
- Parameters:
from –
to –
-
constexpr auto smooth_step(f64 value)¶