Unravel Engine C++ Reference
Loading...
Searching...
No Matches
seq_math.h
Go to the documentation of this file.
1#pragma once
2#include "seq_common.h"
3#include "seq_ease.h"
4#include <algorithm>
5
10namespace seq
11{
12
22template<typename T>
23auto lerp(const T& start, const T& end, float progress, const ease_t& ease_func = ease::linear) -> T;
24
37template<typename InType, typename OutType>
38auto range_map(const InType& in,
39 const decltype(in)& in_start,
40 const decltype(in)& in_end,
41 const OutType& out_start,
42 const decltype(out_start)& out_end,
43 const ease_t& ease_func = ease::linear) -> OutType;
44
53template<typename T>
54auto clamp(const T& value, const T& min, const T& max) -> T
55{
56 return std::min<T>(std::max<T>(value, min), max);
57}
58
65auto square(float x, int n) -> float;
66
72auto flip(float x) -> float;
73
82auto mix(float a, float b, float weight, float t) -> float;
83
91auto crossfade(float a, float b, float t) -> float;
92
99auto scale(float a, float t) -> float;
100
107auto reverse_scale(float a, float t) -> float;
108
114auto arch(float t) -> float;
115
116} // namespace seq
117
118#include "seq_math.hpp"
entt::handle b
entt::handle a
float scale
Definition hub.cpp:25
float linear(float progress)
Definition seq_ease.cpp:292
Provides a sequence-based action management system for controlling and scheduling actions.
auto mix(float a, float b, float weight, float t) -> float
Mixes two values based on a weighted progress factor.
Definition seq_math.cpp:19
auto flip(float x) -> float
Flips a normalized value (1.0 becomes 0.0, 0.0 becomes 1.0).
Definition seq_math.cpp:14
auto start(seq_action action, const seq_scope_policy &scope_policy, hpp::source_location location) -> seq_id_t
Starts a new action.
Definition seq.cpp:8
std::function< float(float)> ease_t
Represents an easing function for interpolation.
Definition seq_common.h:61
auto crossfade(float a, float b, float t) -> float
Creates a crossfade effect between two values based on progress.
Definition seq_math.cpp:25
auto lerp(const T &start, const T &end, float progress, const ease_t &ease_func=ease::linear) -> T
Linearly interpolates between two values based on progress.
Definition seq_math.hpp:8
auto reverse_scale(float a, float t) -> float
Scales a value in reverse by a factor.
Definition seq_math.cpp:35
auto clamp(const T &value, const T &min, const T &max) -> T
Clamps a value to lie between a minimum and maximum.
Definition seq_math.h:54
auto arch(float t) -> float
Computes an arch effect (parabolic curve) based on progress.
Definition seq_math.cpp:40
auto square(float x, int n) -> float
Computes the square of a number raised to a power.
Definition seq_math.cpp:5
auto range_map(const InType &in, const decltype(in)&in_start, const decltype(in)&in_end, const OutType &out_start, const decltype(out_start)&out_end, const ease_t &ease_func=ease::linear) -> OutType
Maps a value from one range to another range, with optional easing.
Definition seq_math.hpp:25
float x