source: rrlib_geometry/tBezierCurve.h @ 3:1b43b0dab355

Last change on this file since 3:1b43b0dab355 was 3:1b43b0dab355, checked in by Tobias Föhst <foehst@…>, 10 years ago

Adapted to changes in rrlib_math rev. 22

File size: 6.5 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) AG Robotersysteme TU Kaiserslautern
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20//
21//----------------------------------------------------------------------
22/*!\file    tBezierCurve.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2009-05-25
27 *
28 * \brief   Contains tBezierCurve
29 *
30 * \b tBezierCurve
31 *
32 * A few words for tBezierCurve
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef _rrlib_geometry_tBezierCurve_h_
37#define _rrlib_geometry_tBezierCurve_h_
38
39#include "rrlib/geometry/tShape.h"
40//----------------------------------------------------------------------
41// External includes (system with <>, local with "")
42//----------------------------------------------------------------------
43#include <vector>
44
45//----------------------------------------------------------------------
46// Internal includes with ""
47//----------------------------------------------------------------------
48#include "rrlib/geometry/tLine.h"
49#include "rrlib/highgui_wrapper/tWindow.h"
50
51//----------------------------------------------------------------------
52// Debugging
53//----------------------------------------------------------------------
54
55//----------------------------------------------------------------------
56// Namespace declaration
57//----------------------------------------------------------------------
58namespace rrlib
59{
60namespace geometry
61{
62
63//----------------------------------------------------------------------
64// Forward declarations / typedefs / enums
65//----------------------------------------------------------------------
66
67//----------------------------------------------------------------------
68// Class declaration
69//----------------------------------------------------------------------
70//! Short description of tBezierCurve
71/*! A more detailed description of tBezierCurve, which
72    Tobias Foehst hasn't done yet !!
73*/
74template <size_t Tdimension, typename TElement, unsigned int Tdegree>
75class tBezierCurve : public tShape<Tdimension, TElement>
76{
77  friend class tBezierCurve < Tdimension, TElement, Tdegree + 1 >;
78
79  typedef geometry::tShape<Tdimension, TElement> tShape;
80
81//----------------------------------------------------------------------
82// Public methods and typedefs
83//----------------------------------------------------------------------
84public:
85
86  static const unsigned int cDEGREE;
87  static const unsigned int cNUMBER_OF_CONTROL_POINTS;
88
89  typedef typename tShape::tPoint::tElement tParameter;
90
91  typedef tBezierCurve < Tdimension, TElement, Tdegree - 1 > tDerivative;
92  typedef std::pair<tBezierCurve, tBezierCurve> tSubdivision;
93
94  tBezierCurve(const std::vector<typename tShape::tPoint> &control_points);
95
96  inline const typename tShape::tPoint &GetControlPoint(size_t i) const
97  {
98    return this->control_points[i];
99  }
100
101  void SetControlPoint(size_t i, const typename tShape::tPoint &point);
102
103  const typename tShape::tPoint operator()(tParameter t) const;
104
105  const TElement GetTwist() const;
106
107  const tSubdivision GetSubdivision() const;
108
109  const tDerivative GetDerivative() const;
110
111  template <unsigned int Tother_degree>
112  const bool GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
113                              const tBezierCurve<Tdimension, TElement, Tother_degree> &other) const;
114
115  const bool GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
116                              const tLine<Tdimension, TElement> &line) const;
117
118  virtual tBezierCurve &Translate(const math::tVector<Tdimension, TElement> &translation);
119  virtual tBezierCurve &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
120  virtual tBezierCurve &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
121
122//----------------------------------------------------------------------
123// Private fields and methods
124//----------------------------------------------------------------------
125private:
126
127  typename tShape::tPoint control_points[Tdegree + 1];
128
129  tBezierCurve(const typename tShape::tPoint * const control_points);
130
131  virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const;
132  virtual void UpdateCenterOfGravity(typename tShape::tPoint &center_of_gravity) const;
133
134  template <unsigned int Tother_degree>
135  const bool GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
136                              const tBezierCurve<Tdimension, TElement, Tother_degree> &other,
137                              tParameter min_parameter, tParameter max_parameter) const;
138
139  const bool GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
140                              const tLine<Tdimension, TElement> &line,
141                              tParameter min_parameter, tParameter max_parameter) const;
142
143};
144
145//----------------------------------------------------------------------
146// Explicit template instantiation
147//----------------------------------------------------------------------
148
149//extern template class tBezierCurve<2, float, 2>;
150//extern template class tBezierCurve<2, float, 3>;
151//
152//extern template class tBezierCurve<3, float, 2>;
153//extern template class tBezierCurve<3, float, 3>;
154//
155//extern template class tBezierCurve<2, double, 2>;
156//extern template class tBezierCurve<2, double, 3>;
157//
158//extern template class tBezierCurve<3, double, 2>;
159//extern template class tBezierCurve<3, double, 3>;
160
161//----------------------------------------------------------------------
162// End of namespace declaration
163//----------------------------------------------------------------------
164}
165}
166
167
168#include "rrlib/geometry/tBezierCurve.hpp"
169
170#endif
Note: See TracBrowser for help on using the repository browser.