21template <
typename D,
typename R>
23 std::function<R(
const D&)>
fn;
37 [[nodiscard]] R
evaluate(
const D& d)
const {
return fn(d); }
64template <
typename D,
typename R,
typename BinaryOp>
67 return { .
fn = [
a,
b, op](
const D& d) -> R {
68 return op(
a(d),
b(d));
81template <
typename A,
typename B,
typename C>
84 return { .
fn = [first, second](
const A&
a) -> C {
85 return second(first(
a));
99 return { .
fn = [t, factor](
const D& d) ->
float {
100 return t(d) * factor;
112 return { .
fn = [t, factor](
const glm::vec3& d) -> glm::vec3 {
113 return t(d) * factor;
128 return { .
fn = [t, lo, hi](
const D& d) ->
float {
129 return std::clamp(t(d), lo, hi);
143 return { .
fn = [t, thresh](
const D& d) ->
float {
145 return v < thresh ? 0.0F : v;
158 return { .
fn = [t](
const D& d) ->
float {
170 return { .
fn = [t](
const glm::vec3& d) -> glm::vec3 {
186 return { .
fn = [
a,
b,
weight](
const D& d) ->
float {
188 return a(d) * (1.0F - w) +
b(d) * w;
201template <
typename D,
typename R>
204 return { .
fn = [predicate, then_t, else_t](
const D& d) -> R {
205 return predicate(d) > 0.0F ? then_t(d) : else_t(d);
Tendency< D, float > invert(const Tendency< D, float > &t)
Negate a scalar-output tendency.
Tendency< D, float > threshold(const Tendency< D, float > &t, float thresh)
Zero output below threshold, pass through above.
Tendency< A, C > chain(const Tendency< A, B > &first, const Tendency< B, C > &second)
Sequential composition: evaluate first, feed result into second.
Tendency< D, float > clamp(const Tendency< D, float > &t, float lo, float hi)
Clamp scalar output to [lo, hi].
Tendency< D, R > select(const Tendency< D, float > &predicate, const Tendency< D, R > &then_t, const Tendency< D, R > &else_t)
Select between two tendencies based on a predicate tendency.
Tendency< D, float > scale(const Tendency< D, float > &t, float factor)
Uniform scaling of a scalar-output tendency.
Tendency< D, R > combine(const Tendency< D, R > &a, const Tendency< D, R > &b, BinaryOp op)
Combine two tendencies with a binary operation on their outputs.
Tendency< D, float > lerp(const Tendency< D, float > &a, const Tendency< D, float > &b, const Tendency< D, float > &weight)
Interpolate between two tendencies controlled by a weight tendency.
std::function< R(const D &)> fn
R operator()(const D &d) const
Evaluate the tendency at a point in the domain.
R evaluate(const D &d) const
Named evaluation (identical to operator())
Typed, composable, stateless callable from domain D to range R.