June 1st 2015, GPS Smoothing Example Continued
← May 27th 2015 GPS Smoothing Example | ● | June 2nd 2015 GPS Smoothing Example Continued →
The next step is to implement a Weighted Least Squares solver (WLS solver for short), which takes the measurements $p_i$ at time points $t_i$ with according weights $w_i$ as input and outputs the coefficients $c_0, c_1$ and $c_2$ of the fitted curve.
We use the WLS solver module of libmini for that purpose:
An example application of the module:
WLS_Point p2={0,1,1};
WLS_Point p3={1,3,1};
miniWLS wls;
wls.push_back(p1);
wls.push_back(p2);
wls.push_back(p3);
wls.quadratic_fit();
vec3 c=wls.coefficients();
std::cout << "coefficients: " << c << std::endl;
This code snippet fits a quadratic polynomial $f(t)=c_0+c_1t+c_2t^2$ to the points (−1,1), (0,1) and (1,3) with the weights 1, 1 and 1.
The corresponding coefficients are
Let’s check:
Fits!
← May 27th 2015 GPS Smoothing Example | ● | June 2nd 2015 GPS Smoothing Example Continued →