Warning, file /education/kstars/kstars/ekos/focus/polynomialfit.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*
0002     SPDX-FileCopyrightText: 2019 Hy Murveit <hy-1@murveit.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include <QVector>
0010 #include <qcustomplot.h>
0011 
0012 namespace Ekos
0013 {
0014 
0015 class PolynomialFit
0016 {
0017 public:
0018     // Constructor. Pass in the degree of the desired polynomial fit, and a vector with the x and y values.
0019     // The constructor solves for the polynomial coefficients.
0020     PolynomialFit(int degree, uint8_t maxCount, const QVector<double>& x, const QVector<double>& y);
0021     PolynomialFit(int degree, const QVector<int>& x, const QVector<double>& y);
0022 
0023     // Returns the minimum position and value in the pointers for the solved polynomial.
0024     // Returns false if the polynomial couldn't be solved.
0025     bool findMinimum(double expected, double minPosition, double maxPosition, double *position, double *value);
0026 
0027     /**
0028      * @brief Polynomial function f(x)
0029      * @param x argument
0030      * @return f(x)
0031      */
0032     double f(double x);
0033 
0034 
0035 private:
0036     // Solves for the polynomial coefficients.
0037     void solve(const QVector<double>& positions, const QVector<double>& values);
0038 
0039     // Calculates the value of the polynomial at x.
0040     // Params will be cast to a PolynomialFit*.
0041     static double polynomialFunction(double x, void *params);
0042 
0043     // Polynomial degree.
0044     int degree;
0045     // The data values.
0046     QVector<double> x, y;
0047     // The solved polynomial coefficients.
0048     std::vector<double> coefficients;
0049 };
0050 }