18template <
typename D,
typename R>
21 return { .
fn = [value](
const D&) -> R {
return value; } };
50 const glm::vec3& anchor,
56 return { .
fn = [anchor,
radius](
const glm::vec3& p) ->
float {
57 return glm::length(p - anchor) /
radius;
61 return { .fn = [anchor, r_sq](
const glm::vec3& p) ->
float {
62 glm::vec3 d = p - anchor;
63 return glm::dot(d, d) / r_sq;
67 return { .fn = [anchor,
radius](
const glm::vec3& p) ->
float {
68 glm::vec3 d = glm::abs(p - anchor);
69 return (d.x + d.y + d.z) /
radius;
72 return { .fn = [anchor,
radius](
const glm::vec3& p) ->
float {
73 glm::vec3 d = glm::abs(p - anchor);
74 return std::max({ d.x, d.y, d.z }) /
radius;
77 return { .fn = [anchor,
radius](
const glm::vec3& p) ->
float {
78 return glm::length(p - anchor) /
radius;
96 return { .
fn = [coefficients](
const float& x) ->
float {
100 for (
float coefficient : std::views::reverse(coefficients)) {
101 result += coefficient * power;
116 return { .
fn = [edge0, edge1](
const float& x) ->
float {
117 float t = std::clamp((x - edge0) / (edge1 - edge0), 0.0F, 1.0F);
118 return t * t * (3.0F - 2.0F * t);
130 return { .
fn = [k, midpoint](
const float& x) ->
float {
131 return 1.0F / (1.0F + std::exp(-k * (x - midpoint)));
ScalarField transfer_curve(const std::vector< float > &coefficients)
Transfer curve from polynomial coefficients (highest power first)
ScalarField smoothstep(float edge0, float edge1)
Smoothstep: cubic Hermite interpolation between two edges.
ScalarField sigmoid(float k, float midpoint=0.0F)
Sigmoid: 1 / (1 + e^(-k * (x - midpoint)))
DistanceMetric
Distance computation strategy for spatial queries.
SpatialField distance(const glm::vec3 &anchor, float radius, DistanceMetric metric=DistanceMetric::EUCLIDEAN)
Normalized distance from an anchor point using the specified metric.
Tendency< D, R > constant(R value)
Tendency returning a fixed value regardless of input.
std::function< R(const D &)> fn
Typed, composable, stateless callable from domain D to range R.