#pragma once #include #include const int MAX_POINTS = 16; class Newton: public QWidget { Q_OBJECT private: int numPoints; double a[MAX_POINTS]; // Coefficients of Newton polynomial double nodeX[MAX_POINTS], nodeY[MAX_POINTS]; QPointF map(QPointF) const; QPointF invMap(QPointF) const; double xmin, xmax, ymin, ymax; double xCoeff, yCoeff; public: Newton(QWidget *parent = 0); void defineMap(); void drawAxes(QPainter*); void drawPoints(QPainter*); void drawPolynomial(QPainter*); protected: void paintEvent(QPaintEvent* event); void mousePressEvent(QMouseEvent* event); public slots: void clear(); }; // Value of Newton interpolation polynomial in point t double newtonPolValue( int n, // Number of nodes - 1 const double* x, // Nodes of interpolation: x0, x1, ..., xn const double* a, // Coefficients of Newton polynomial double t ); // Compute the coefficients of Newton interpolation polynomial void computeNewtonPol( int n, // Number of nodes - 1 const double* x, // Nodes of interpolation: x0, x1, ..., xn const double* y, // Values in these nodes double* a // Coefficients of Newton polynomial );