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

◆ straightness() [1/2]

float MayaFlux::Kinesis::straightness ( const Memory::HistoryBuffer< glm::vec2 > &  history,
size_t  window 
)
inlinenoexcept

Straightness of a path over a window, 1.0 is a straight line.

Parameters
historyBuffer of positions, capacity >= window
windowNumber of samples, minimum 2
Returns
net_displacement / path_length, or 0 when path_length is below 1e-6 to avoid dividing by a stationary point

A gesture that doubles back on itself drives this toward 0 even though individual segment speeds may be high; a gesture that moves directly toward one point holds this near 1.0 regardless of speed.

Definition at line 485 of file Differential.hpp.

486{
487 const float len = path_length(history, window);
488 if (len < 1e-6F)
489 return 0.0F;
490 return net_displacement(history, window) / len;
491}
float path_length(const Memory::HistoryBuffer< glm::vec2 > &history, size_t window) noexcept
Path length accumulated across the newest window positions.
float net_displacement(const Memory::HistoryBuffer< glm::vec2 > &history, size_t window) noexcept
Net displacement across the newest window positions.

References net_displacement(), and path_length().

Referenced by straightness().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: