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