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

◆ heading_vector() [1/4]

glm::vec2 MayaFlux::Kinesis::heading_vector ( const Memory::HistoryBuffer< glm::vec2 > &  history,
double  dt 
)
inlinenoexcept

Unit direction of a vec2 first difference.

Parameters
historyBuffer with capacity >= 2
dtElapsed time between samples 0 and 1
Returns
Normalized velocity, or the zero vector when speed is below 1e-6 to avoid dividing by zero on a stationary point

Definition at line 308 of file Differential.hpp.

309{
310 const glm::vec2 v = velocity(history, dt);
311 const float len = glm::length(v);
312 return (len > 1e-6F) ? (v / len) : glm::vec2(0.0F);
313}
T velocity(const Memory::HistoryBuffer< T > &history, double dt) noexcept
First difference: rate of change of position.

References velocity().

Referenced by heading_vector(), and heading_vector().

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