Fawkes API Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * spline.h - Cubic spline curve 00004 * 00005 * Created: Tue Oct 07 18:57:42 2008 00006 * Copyright 2008 Daniel Beck 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. A runtime exception applies to 00014 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00015 * 00016 * This program is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 * GNU Library General Public License for more details. 00020 * 00021 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00022 */ 00023 00024 #ifndef __GEOMETRY_SPLINE_H_ 00025 #define __GEOMETRY_SPLINE_H_ 00026 00027 #include <geometry/transformable.h> 00028 #include <geometry/hom_point.h> 00029 #include <geometry/bezier.h> 00030 #include <vector> 00031 00032 namespace fawkes { 00033 00034 class SplineDrawer; 00035 00036 class Spline : public Transformable 00037 { 00038 friend class fawkes::SplineDrawer; 00039 00040 public: 00041 Spline(); 00042 Spline(const std::vector<HomPoint>& control_points); 00043 virtual ~Spline(); 00044 00045 void set_control_points(const std::vector<HomPoint>& control_points); 00046 void set_control_point(unsigned int i, const HomPoint& p); 00047 00048 const std::vector<HomPoint>& get_control_points() const; 00049 const std::vector<Bezier>& get_bezier_curves() const; 00050 00051 HomPoint eval(unsigned int bezier_index, float t); 00052 HomVector tangent(unsigned int bezier_index, float t); 00053 HomVector tangent(unsigned int point_index); 00054 std::vector<HomPoint> approximate(unsigned int num_subdivisions = 4); 00055 00056 protected: 00057 // transformable 00058 virtual void register_primitives(); 00059 virtual void post_transform(); 00060 00061 private: 00062 void construct_bezier_curves(); 00063 00064 std::vector<HomPoint> m_control_points; 00065 std::vector<Bezier> m_bezier_curves; 00066 00067 unsigned int m_num_subdivisions; 00068 }; 00069 00070 } 00071 00072 #endif /* __GEOMETRY_SPLINE_H_ */