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 pi at time points ti with according weights wi as input and outputs the coefficients c0,c1 and c2 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)=c0+c1t+c2t2 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 →