VelocityTracker.h 520 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * VelocityTracker.h
  3. *
  4. * Created on: Jul 19, 2017
  5. * Author: guoxs
  6. */
  7. #ifndef _UTILS_VELOCITY_TRACKER_H_
  8. #define _UTILS_VELOCITY_TRACKER_H_
  9. #include "control/Common.h"
  10. class VelocityTracker {
  11. public:
  12. VelocityTracker();
  13. virtual ~VelocityTracker();
  14. void addMovement(const MotionEvent &ev);
  15. void reset();
  16. float getXVelocity() const;
  17. float getYVelocity() const;
  18. private:
  19. bool canComputeVelocity() const;
  20. private:
  21. int mCurIndex;
  22. MotionEvent mEvents[2];
  23. };
  24. #endif /* _UTILS_VELOCITY_TRACKER_H_ */