#include "util.h" #include void Util::unwrapPhase(std::vector &phase, unsigned int start_index) { for (unsigned int i = start_index + 1; i < phase.size(); i++) { int d = trunc(phase[i] - phase[i-1]) / M_PI; if(d > 0) { // there is larger than a 180° shift between this and the previous phase phase[i] -= 2*M_PI*(int)((d+1)/2); } else if(d < 0) { // there is larger than a -180° shift between this and the previous phase phase[i] -= 2*M_PI*(int)((d-1)/2); } } } void Util::linearRegression(const std::vector &input, double &B_0, double &B_1) { double x_mean = (input.size() - 1.0) / 2.0; double y_mean = std::accumulate(input.begin(), input.end(), 0.0) / input.size(); double ss_xy = 0.0; for(unsigned int i=0;i= 1) { orthVect = QVector2D(point - l2); closestPoint = l2; t0 = 1; } else { auto intersect = l1 + t0 * M; orthVect = QVector2D(point - intersect); closestPoint = intersect; } if(closestLinePoint) { *closestLinePoint = closestPoint; } if(pointRatio) { *pointRatio = t0; } return orthVect.length(); }