From 18f329e9480fca75210bb7496e5b4bc987b4ad8f Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Sun, 3 Jun 2012 14:18:26 -0700 Subject: Implement a weighted least squares VelocityTracker strategy. No change to the default strategy. Bug: 6413587 Change-Id: I08eb6f9a511e65ad637359b55b5993c26ba93b40 --- include/androidfw/VelocityTracker.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/androidfw/VelocityTracker.h b/include/androidfw/VelocityTracker.h index e600c5a..262a51b 100644 --- a/include/androidfw/VelocityTracker.h +++ b/include/androidfw/VelocityTracker.h @@ -138,8 +138,23 @@ public: */ class LeastSquaresVelocityTrackerStrategy : public VelocityTrackerStrategy { public: + enum Weighting { + // No weights applied. All data points are equally reliable. + WEIGHTING_NONE, + + // Weight by time delta. Data points clustered together are weighted less. + WEIGHTING_DELTA, + + // Weight such that points within a certain horizon are weighed more than those + // outside of that horizon. + WEIGHTING_CENTRAL, + + // Weight such that points older than a certain amount are weighed less. + WEIGHTING_RECENT, + }; + // Degree must be no greater than Estimator::MAX_DEGREE. - LeastSquaresVelocityTrackerStrategy(uint32_t degree); + LeastSquaresVelocityTrackerStrategy(uint32_t degree, Weighting weighting = WEIGHTING_NONE); virtual ~LeastSquaresVelocityTrackerStrategy(); virtual void clear(); @@ -167,7 +182,10 @@ private: } }; + float chooseWeight(uint32_t index) const; + const uint32_t mDegree; + const Weighting mWeighting; uint32_t mIndex; Movement mMovements[HISTORY_SIZE]; }; -- cgit v1.1