MayaFlux 1.0.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ sample_table()

double MayaFlux::Kinesis::sample_table ( std::span< const double >  table,
double  t 
)
inlinenoexcept

Read an evenly spaced table at a position in [0, 1], interpolating linearly.

Parameters
tableSamples spread evenly from position 0 (first) to 1 (last)
tPosition, clamped to [0, 1]
Returns
Interpolated value; zero for an empty table, the entry for a single one

The lookup under TimeMaps::piecewise_linear and the table kernels in Discrete/Kernels.

Definition at line 79 of file Scalar.hpp.

80{
81 const size_t n = table.size();
82 if (n == 0)
83 return 0.0;
84 if (n == 1)
85 return table.front();
86
87 const double x = std::clamp(t, 0.0, 1.0) * static_cast<double>(n - 1);
88 const auto i = std::min(static_cast<size_t>(x), n - 2);
89 const double f = x - static_cast<double>(i);
90 return table[i] + (table[i + 1] - table[i]) * f;
91}

Referenced by MayaFlux::Kinesis::TimeMaps::piecewise_linear().

+ Here is the caller graph for this function: