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

◆ approach_rate()

double MayaFlux::Kinesis::approach_rate ( std::span< const double >  a,
std::span< const double >  b,
double  dt 
)
inlinenoexcept

Rate at which two streams approach or separate.

Parameters
aFirst span, chronological order
bSecond span, chronological order, same length as a
dtSeconds per sample
Returns
Least-squares slope of |a - b| over the window, per second; negative means the streams are converging, positive diverging

Distinct from correlation, which asks whether two streams move in the same direction as each other, not whether they are getting nearer. Two streams can correlate strongly while one holds steady and the other drifts away from it, or diverge while both move in the same direction at different rates. This is the direct measure of mutual approach the dancers-and-a-third-point case needs: not whether the third point's motion resembles either hand's, but whether it is closing on the gap between them.

Operates on scalar streams. A caller with vector positions supplies the scalar separation (glm::length of the difference, or a projected distance) rather than raw components, since "approaching" is a statement about a single distance, not about three independent axes each separately trending.

Definition at line 192 of file Relation.hpp.

194{
195 const size_t n = a.size();
196 if (n != b.size() || n < 2 || dt <= 0.0)
197 return 0.0;
198
199 std::vector<double> separation(n);
200 for (size_t i = 0; i < n; ++i)
201 separation[i] = std::abs(a[i] - b[i]);
202
203 return Stochastic::Estimate::trend_slope(separation) / dt;
204}
size_t a
size_t b

References a, b, and MayaFlux::Kinesis::Stochastic::Estimate::trend_slope().

+ Here is the call graph for this function: