emilib
Classes | Public Types | Public Member Functions | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
emilib::MovementTracker< T > Class Template Reference

#include <movement_tracker.hpp>

Classes

struct  TimePosPair
 

Public Types

using value_type = T
 

Public Member Functions

void clear ()
 
void add (const T &pos, double time)
 
std::vector< T > points () const
 
bool empty () const
 
size_t size () const
 
double start_time () const
 
start_pos () const
 
double latest_time () const
 
latest_pos () const
 
rel () const
 Last movement delta.
 
double duration () const
 
virtual T velocity (double now) const
 
velocity () const
 
template<typename F >
bool is_still (F max_dist, double duration) const
 Has all movement been within "max_dist" radius, during the last "duration" seconds?
 
void flush (double now)
 Flush out oldes entries.
 

Protected Types

using TimePosList = std::deque< TimePosPair >
 

Protected Member Functions

bool velocity_calc_begin (size_t &out_index, double now) const
 From where shall we calculate velocity? Return false on "not at all".
 

Static Protected Member Functions

static constexpr size_t min_velocity_samples ()
 The minimum number of samples for there to be any velocity calculated.
 
static constexpr double min_velocity_time ()
 Minimum time before we have a good velocity.
 
static constexpr double velocity_time ()
 The time over which we calculate velocity.
 

Protected Attributes

bool _has_start = false
 
TimePosPair _start
 
TimePosList _list
 
double _max_history_time = 10
 

Detailed Description

template<typename T>
class emilib::MovementTracker< T >

Tracks movement and gives info about velocity. 'T' is the type of movement we track (float for scoll, Vec2 for position, ...)

Member Function Documentation

◆ velocity()

template<typename T>
virtual T emilib::MovementTracker< T >::velocity ( double  now) const
inlinevirtual

Return T() on fail Calculates the average velocity over the last VelocityTime() seconds.

Reimplemented in emilib::RotationTracker.


The documentation for this class was generated from the following file: