-->

分類

2016年3月15日 星期二

Android VelocivtyTracker

VelocityTracker.cpp

裡面的LeastSquaresVelocityTrackerStrategy很有趣
我感覺是類似利用位移的物公式x = x0 + v * t + c * a * (t^2) (x為總位移, x0為某常數, t為時間,v為速度, c為某常數,a為加速度,以degree為2的情況來看)
就是利用之前記錄下的movement及time去建立一個矩陣去解least square(解x0 , v, c*a)
主要的解釋在這裡:
* That is to say, the function that generated the input data can be approximated
* by y(x) ~= B[0] + B[1] x + B[2] x^2 + ... + B[n] x^n.
*
* The coefficient of determination (R^2) is also returned to describe the goodness
* of fit of the model for the given data.  It is a value between 0 and 1, where 1
* indicates perfect correspondence.
*
* This function first expands the X vector to a m by n matrix A such that
* A[i][0] = 1, A[i][1] = X[i], A[i][2] = X[i]^2, ..., A[i][n] = X[i]^n, then
* multiplies it by w[i]./
*

而其中y(x) ~= B[0] + B[1] x + B[2] x^2 + ... + B[n] x^n.
這裡y(x)就是位移(movement), x是時間, degree只有2所以就是解y(x) ~= B[0] + B[1] x + B[2] x^2
再對照x = x0 + v * t + c * a * (t^2)可知 B[1]就是v, 所以在最後return velocity時
(VelocityTracker::getVelocity裡)為 *outVx = estimator.xCoeff[1];

註解裡面的w[i]是權重,這個就還沒仔細研究, 不過權重目的應該是突顯某個B[i]的重要性

當然以上都只是我的感覺啦

沒有留言:

張貼留言