nuclear@0: #ifndef CURVE_H_ nuclear@0: #define CURVE_H_ nuclear@0: nuclear@0: #include nuclear@0: #include nuclear@0: nuclear@0: enum CurveType { nuclear@0: CURVE_LINEAR, nuclear@0: CURVE_HERMITE, nuclear@0: CURVE_BSPLINE nuclear@0: }; nuclear@0: nuclear@0: class Curve { nuclear@0: private: nuclear@0: std::vector cp; nuclear@0: CurveType type; nuclear@0: nuclear@0: public: nuclear@0: Curve(CurveType type = CURVE_HERMITE); nuclear@0: nuclear@0: void set_type(CurveType type); nuclear@0: CurveType get_type() const; nuclear@0: nuclear@0: void add_point(const Vector2 &p, float weight = 1.0f); nuclear@0: bool remove_point(int idx); nuclear@0: nuclear@0: int nearest_point(const Vector2 &p); nuclear@0: nuclear@2: bool empty() const; nuclear@2: int size() const; nuclear@2: Vector3 &operator [](int idx); nuclear@2: const Vector3 &operator [](int idx) const; nuclear@2: nuclear@0: const Vector3 &get_homo_point(int idx) const; // homogeneous point nuclear@0: Vector2 get_point(int idx) const; nuclear@0: float get_weight(int idx) const; nuclear@0: nuclear@0: bool set_point(int idx, const Vector2 &p, float weight = 1.0f); nuclear@0: bool set_weight(int idx, float weight); nuclear@2: // move point without changing its weight nuclear@2: bool move_point(int idx, const Vector2 &p); nuclear@0: nuclear@0: Vector2 interpolate(float t, CurveType type) const; nuclear@0: Vector2 interpolate(float t) const; nuclear@0: Vector2 operator ()(float t) const; nuclear@0: }; nuclear@0: nuclear@0: #endif // CURVE_H_