bezier.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef __GEOMETRY_BEZIER_H_
00025 #define __GEOMETRY_BEZIER_H_
00026
00027 #include <geometry/transformable.h>
00028 #include <vector>
00029
00030 namespace fawkes {
00031 class HomPoint;
00032 class HomVector;
00033
00034 class Bezier : public Transformable
00035 {
00036 public:
00037 Bezier();
00038 Bezier(const std::vector<HomPoint>& control_points);
00039 Bezier(const Bezier& b);
00040 ~Bezier();
00041
00042 void set_control_points(const std::vector<HomPoint>& control_points);
00043 void set_control_point(unsigned int index, const HomPoint& control_point);
00044
00045 std::vector<HomPoint> get_control_points() const;
00046 HomPoint get_control_point(unsigned int i) const;
00047
00048 unsigned int degree() const;
00049
00050 HomPoint eval(float t);
00051 HomVector tangent_at_t(float t);
00052 HomVector tangent_at_point(unsigned int index);
00053 void subdivide(float t, Bezier& c, Bezier& d);
00054 const std::vector<HomPoint>& approximate(unsigned int num_subdivisions = 4);
00055
00056 protected:
00057
00058 virtual void register_primitives();
00059 virtual void post_transform();
00060
00061 private:
00062 void init_dclj_array();
00063 unsigned int get_dclj_array_index(unsigned int k, unsigned int i) const;
00064
00065 std::vector<HomPoint> m_control_points;
00066 std::vector<HomPoint> m_approximation;
00067 unsigned int m_num_subdivisions;
00068
00069 HomPoint de_casteljau(unsigned int k, unsigned int i, float t);
00070
00071 std::pair<HomPoint*, bool>* m_de_casteljau_points;
00072 unsigned int m_dclj_array_size;
00073
00074 unsigned int m_num_control_points;
00075
00076 float m_last_t;
00077 };
00078
00079 }
00080
00081 #endif