27 return { .
fn = [from, to, duration](
const double& t) ->
double {
28 if (duration <= 0.0) {
31 return map_clamped<double>(t, 0.0, duration, from, to);
47 return { .
fn = [from, to, duration](
const double& t) ->
double {
48 if (duration <= 0.0 || from <= 0.0 || to <= 0.0) {
51 return from * std::pow(to / from, std::clamp(t / duration, 0.0, 1.0));
66 const double s = std::max(t, 0.0);
80 return { .
fn = [lo, hi,
velocity, start](
const double& t) ->
double {
81 return ping_pong<double>(start +
velocity * t, lo, hi);
97 return { .
fn = [origin,
rate, lag = std::move(lag)](
const double& t) ->
double {
98 return origin +
rate * t - lag(t);
120 auto state = std::make_shared<State>(State { .position = start, .last = 0.0 });
122 return { .
fn = [state, start,
velocity = std::move(
velocity)](
const double& t) ->
double {
123 if (t < state->last) {
124 state->position = start;
128 state->position += *
velocity * (t - state->last);
130 return state->position;
142 return { .
fn = [
points = std::move(
points), duration](
const double& t) ->
double {
146 if (
points.size() == 1 || duration <= 0.0) {
std::optional< glm::vec3 > position
std::vector< glm::vec2 > * points
TimeMap exponential(double from, double to, double duration)
Geometric path from one value to another, then constant.
TimeMap triangle(double lo, double hi, double velocity, double start)
Triangle wave between two positions.
TimeMap lagged(double origin, double rate, TimeMap lag)
Position of a moving reference minus a lag that can itself change.
TimeMap linear(double from, double to, double duration)
Straight path from one position to another, then constant.
TimeMap quadratic(double start, double velocity, double acceleration)
Constant acceleration from an initial velocity.
TimeMap integrated(double start, std::shared_ptr< const double > velocity)
Position that integrates a velocity you can change while it plays.
TimeMap piecewise_linear(std::vector< double > points, double duration)
Piecewise linear path through evenly spaced positions.
T acceleration(const Memory::HistoryBuffer< T > &history, double dt) noexcept
Second difference: rate of change of velocity.
T velocity(const Memory::HistoryBuffer< T > &history, double dt) noexcept
First difference: rate of change of position.
double sample_table(std::span< const double > table, double t) noexcept
Read an evenly spaced table at a position in [0, 1], interpolating linearly.
std::function< R(const D &)> fn
Typed, composable, stateless callable from domain D to range R.