Class containing interpolation and easing functions optimized for fixed-point arithmetic.
This class provides a comprehensive set of interpolation and easing functions designed for game development. All functions are implemented using fixed-point arithmetic for consistent behavior across platforms.
Key features:
#include <interpolation.hpp>
Static Public Member Functions | |
static constexpr Fxp | BounceEaseIn (const Fxp &start, const Fxp &end, const Fxp &t) |
Bounce ease-in interpolation for reverse bouncing ball effect. | |
static constexpr Fxp | BounceEaseOut (const Fxp &start, const Fxp &end, const Fxp &t) |
Bounce ease-out interpolation for bouncing ball effect. | |
static constexpr Fxp | Clamp (const Fxp &value, const Fxp &min, const Fxp &max) |
Clamps a value between minimum and maximum bounds. | |
static constexpr Fxp | CubicEaseIn (const Fxp &start, const Fxp &end, const Fxp &t) |
Cubic ease-in interpolation for stronger acceleration. | |
static constexpr Fxp | CubicEaseOut (const Fxp &start, const Fxp &end, const Fxp &t) |
Cubic ease-out interpolation for stronger deceleration. | |
static constexpr Fxp | EaseIn (const Fxp &start, const Fxp &end, const Fxp &t) |
Quadratic ease-in interpolation for accelerating motion. | |
static constexpr Fxp | EaseOut (const Fxp &start, const Fxp &end, const Fxp &t) |
Quadratic ease-out interpolation for decelerating motion. | |
static constexpr Fxp | ElasticEaseIn (const Fxp &start, const Fxp &end, const Fxp &t) |
Elastic ease-in interpolation for spring-like motion. | |
static constexpr Fxp | Lerp (const Fxp &start, const Fxp &end, const Fxp &t) |
Linear interpolation between two fixed-point values. | |
static constexpr Fxp | Smoothstep (const Fxp &start, const Fxp &end, const Fxp &t) |
Smoothstep interpolation for smooth acceleration and deceleration. | |
|
inlinestaticconstexpr |
Bounce ease-in interpolation for reverse bouncing ball effect.
Implements bouncing by reversing BounceEaseOut. Creates a series of bounces that converge to the start.
The motion consists of four phases in reverse:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Bounce ease-out interpolation for bouncing ball effect.
Implements bouncing using piecewise quadratic functions. Simulates diminishing bounces of an elastic ball.
The motion consists of four phases:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Clamps a value between minimum and maximum bounds.
Ensures a value stays within specified bounds using the formula: result = min(max(value, min), max)
Clamping behavior:
Common uses:
value | Value to be clamped |
min | Minimum allowed value |
max | Maximum allowed value |
|
inlinestaticconstexpr |
Cubic ease-in interpolation for stronger acceleration.
Implements cubic easing using the formula: t³
The easing produces this motion:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Cubic ease-out interpolation for stronger deceleration.
Implements cubic easing using the formula: (t - 1)³ + 1
The easing produces this motion:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Quadratic ease-in interpolation for accelerating motion.
Implements quadratic easing using the formula: t²
The easing produces this motion:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Quadratic ease-out interpolation for decelerating motion.
Implements quadratic easing using the formula: -t * (t - 2)
The easing produces this motion:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Elastic ease-in interpolation for spring-like motion.
Implements elastic easing with configurable period and amplitude. Uses quadratic approximation of sine for efficiency.
The easing produces this motion:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Linear interpolation between two fixed-point values.
Performs linear interpolation (lerp) between start and end values using the formula: result = start + (end - start) * t
The interpolation follows this pattern:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor in range [0,1] |
|
inlinestaticconstexpr |
Smoothstep interpolation for smooth acceleration and deceleration.
Implements Ken Perlin's smoothstep function using the formula: 3t² - 2t³
The smoothstep produces this behavior:
Common uses:
start | Starting value of the interpolation |
end | Ending value of the interpolation |
t | Interpolation factor, automatically clamped to [0,1] |