curvedraw
annotate src/curve.h @ 7:5ace6f6f4973
fixed the build on linux
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 18 Dec 2015 14:38:41 +0200 |
parents | ce7aa9a0594c |
children | 84a647283237 |
rev | line source |
---|---|
nuclear@0 | 1 #ifndef CURVE_H_ |
nuclear@0 | 2 #define CURVE_H_ |
nuclear@0 | 3 |
nuclear@0 | 4 #include <vector> |
nuclear@0 | 5 #include <vmath/vmath.h> |
nuclear@0 | 6 |
nuclear@0 | 7 enum CurveType { |
nuclear@0 | 8 CURVE_LINEAR, |
nuclear@0 | 9 CURVE_HERMITE, |
nuclear@0 | 10 CURVE_BSPLINE |
nuclear@0 | 11 }; |
nuclear@0 | 12 |
nuclear@0 | 13 class Curve { |
nuclear@0 | 14 private: |
nuclear@0 | 15 std::vector<Vector3> cp; |
nuclear@0 | 16 CurveType type; |
nuclear@0 | 17 |
nuclear@0 | 18 public: |
nuclear@0 | 19 Curve(CurveType type = CURVE_HERMITE); |
nuclear@0 | 20 |
nuclear@0 | 21 void set_type(CurveType type); |
nuclear@0 | 22 CurveType get_type() const; |
nuclear@0 | 23 |
nuclear@0 | 24 void add_point(const Vector2 &p, float weight = 1.0f); |
nuclear@0 | 25 bool remove_point(int idx); |
nuclear@0 | 26 |
nuclear@0 | 27 int nearest_point(const Vector2 &p); |
nuclear@0 | 28 |
nuclear@2 | 29 bool empty() const; |
nuclear@2 | 30 int size() const; |
nuclear@2 | 31 Vector3 &operator [](int idx); |
nuclear@2 | 32 const Vector3 &operator [](int idx) const; |
nuclear@2 | 33 |
nuclear@0 | 34 const Vector3 &get_homo_point(int idx) const; // homogeneous point |
nuclear@0 | 35 Vector2 get_point(int idx) const; |
nuclear@0 | 36 float get_weight(int idx) const; |
nuclear@0 | 37 |
nuclear@0 | 38 bool set_point(int idx, const Vector2 &p, float weight = 1.0f); |
nuclear@0 | 39 bool set_weight(int idx, float weight); |
nuclear@2 | 40 // move point without changing its weight |
nuclear@2 | 41 bool move_point(int idx, const Vector2 &p); |
nuclear@0 | 42 |
nuclear@0 | 43 Vector2 interpolate(float t, CurveType type) const; |
nuclear@0 | 44 Vector2 interpolate(float t) const; |
nuclear@0 | 45 Vector2 operator ()(float t) const; |
nuclear@0 | 46 }; |
nuclear@0 | 47 |
nuclear@0 | 48 #endif // CURVE_H_ |