# Kstars

polynomialfit.h
1 /*
2  SPDX-FileCopyrightText: 2019 Hy Murveit <[email protected]>
3
5 */
6
7 #pragma once
8
9 #include <QVector>
10 #include <qcustomplot.h>
11
12 namespace Ekos
13 {
14
15 class PolynomialFit
16 {
17 public:
18  // Constructor. Pass in the degree of the desired polynomial fit, and a vector with the x and y values.
19  // The constructor solves for the polynomial coefficients.
20  PolynomialFit(int degree, uint8_t maxCount, const QVector<double>& x, const QVector<double>& y);
21  PolynomialFit(int degree, const QVector<int>& x, const QVector<double>& y);
22
23  // Returns the minimum position and value in the pointers for the solved polynomial.
24  // Returns false if the polynomial couldn't be solved.
25  bool findMinimum(double expected, double minPosition, double maxPosition, double *position, double *value);
26
27  /**
28  * @brief Polynomial function f(x)
29  * @param x argument
30  * @return f(x)
31  */
32  double f(double x);
33
34
35 private:
36  // Solves for the polynomial coefficients.
37  void solve(const QVector<double>& positions, const QVector<double>& values);
38
39  // Calculates the value of the polynomial at x.
40  // Params will be cast to a PolynomialFit*.
41  static double polynomialFunction(double x, void *params);
42
43  // Polynomial degree.
44  int degree;
45  // The data values.
46  QVector<double> x, y;
47  // The solved polynomial coefficients.
48  std::vector<double> coefficients;
49 };
50 }
Ekos is an advanced Astrophotography tool for Linux. It is based on a modular extensible framework to...
Definition: align.cpp:70
QAction * solve(const QObject *recvr, const char *slot, QObject *parent)
This file is part of the KDE documentation.