#ifndef BEZIER
#define BEZIER
#include "point3d.hpp"
#include <vector>


class Bezier{
private:
	std::vector<Point3d> bezier;
	float time; // Time it takes to reach the end in seconds
public:
	Bezier(void):time{0.0} {};
	Bezier(std::vector<Point3d> bez, float t):bezier{bez}, time{t} {};
	Bezier(const Bezier& other):bezier{other.bezier}, time{other.time} {};
	Point3d eval(double t) const;
	std::vector<Point3d> reduce(double t) const;
	Point3d getTan(double t) const;
	float getTime(void) const { return this->time;}
	void affiche(void);
	void set(unsigned int i, const Point3d& val);
	Point3d& operator[](int i) {return bezier[i];}

	Bezier& operator=(const Bezier&);
	
	friend class BAnim;
	// Declaring friend otherwise compiler can't find the correct one with P3d
	friend Bezier lerp(const Bezier& b1, const Bezier& b2, float t);
};

class BAnim {
private:
	std::vector<Bezier> bezs;
	float totalTime;
	float (*evalFunc)(float, float);
public:
	static float baseEval(float, float);
	BAnim(void);
	BAnim(std::vector<Bezier> b);
	BAnim(float(f)(float, float));
	BAnim(std::vector<Bezier> b, float(f)(float, float));
	void push_back(Bezier& b);

	const Bezier& getBezier(float t) const;
	Point3d evalAnim(float);
	Point3d getAnimTan(float);
	float reduceToTime(float)const;
};

#endif
