#ifndef WIDGETS_GRAPHPLOTTER_SPLINE_H
#define WIDGETS_GRAPHPLOTTER_SPLINE_H

#include "Common.h"
#include "Vector2D.h"


// -- TDE NAMESPACE ----------------------------------------------------

namespace TDE {

// -- Widgets NAMESPACE ------------------------------------------------

namespace Widgets {

namespace Plot {


class Spline
{
public:
	// S(x) = c[0] + c[1] * (x - x0) + c[2] * (x - x0)**2 + ... + c[N] * (x - x0) ** N

	Spline(int deg = 3);

	int degree() const 					{ return (coeff.size() - 1); }
	int degree(int n)					{ int old = degree(); coeff.resize(n+1, 0.0); return old; }

	double compute(double x) const;

	double operator()(double x) const 	{ return compute(x); }

	double x0, x1;
	std::vector<double> coeff;
};


} /* end of namespace Plot */

} /* end of namespace Widgets */

} /* end of namespace TDE */

#endif /* WIDGETS_GRAPHPLOTTER_SPLINE_H */
