source: rrlib_geometry/curves/tSplineCurve.h @ 17:3daa58ced492

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

Merged with changes from rrlab

File size: 6.0 KB
Line 
1//
2// You received this file as part of RRLib
3// Robotics Research Library
4//
5// Copyright (C) Finroc GbR (finroc.org)
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    tSplineCurve.h
23 *
24 * \author  Tobias Foehst
25 *
26 * \date    2010-09-01
27 *
28 * \brief   Contains tSplineCurve
29 *
30 * \b tSplineCurve
31 *
32 * A few words for tSplineCurve
33 *
34 */
35//----------------------------------------------------------------------
36#ifndef __rrlib__geometry__curves__tSplineCurve_h__
37#define __rrlib__geometry__curves__tSplineCurve_h__
38
39#include "rrlib/geometry/tShape.h"
40//----------------------------------------------------------------------
41// External includes (system with <>, local with "")
42//----------------------------------------------------------------------
43
44//----------------------------------------------------------------------
45// Internal includes with ""
46//----------------------------------------------------------------------
47#include "rrlib/geometry/curves/tBezierCurve.h"
48
49//----------------------------------------------------------------------
50// Debugging
51//----------------------------------------------------------------------
52
53//----------------------------------------------------------------------
54// Namespace declaration
55//----------------------------------------------------------------------
56namespace rrlib
57{
58namespace geometry
59{
60
61//----------------------------------------------------------------------
62// Forward declarations / typedefs / enums
63//----------------------------------------------------------------------
64
65//----------------------------------------------------------------------
66// Class declaration
67//----------------------------------------------------------------------
68//! Short description of tLine
69/*! A more detailed description of tLine, which
70    Tobias Foehst hasn't done yet !!
71*/
72template < size_t Tdimension, typename TElement, unsigned int Tdegree = 3 >
73class tSplineCurve : public tShape<Tdimension, TElement>
74{
75
76  typedef geometry::tShape<Tdimension, TElement> tShape;
77
78//----------------------------------------------------------------------
79// Public methods and typedefs
80//----------------------------------------------------------------------
81public:
82
83  static const unsigned int cDEGREE;
84
85  typedef geometry::tBezierCurve<Tdimension, TElement, Tdegree> tBezierCurve;
86  typedef typename tBezierCurve::tParameter tParameter;
87
88  template <typename TIterator>
89  tSplineCurve(TIterator begin, TIterator end);
90
91  template <typename TSTLContainer>
92  explicit tSplineCurve(const TSTLContainer &control_points);
93
94  inline const size_t GetNumberOfControlPoints() const
95  {
96    return this->control_points.size();
97  }
98
99  inline const std::vector<typename tShape::tPoint> &GetControlPoints() const
100  {
101    return this->control_points;
102  }
103
104  inline const typename tShape::tPoint &GetControlPoint(size_t i) const
105  {
106    return this->control_points[i];
107  }
108
109  void SetControlPoint(size_t i, const typename tShape::tPoint &point);
110
111  void AppendControlPoint(const typename tShape::tPoint &point);
112
113  void InsertControlPoint(typename std::vector<typename tShape::tPoint>::iterator position, const typename tShape::tPoint &point);
114
115  const typename tShape::tPoint operator()(tParameter t) const;
116
117  const unsigned int GetNumberOfSegments() const;
118
119  const tBezierCurve GetBezierCurveForParameter(tParameter t) const;
120
121  const tBezierCurve GetBezierCurveForParameter(tParameter t, tParameter &local_t) const;
122
123  virtual const tBezierCurve GetBezierCurveForSegment(unsigned int i) const = 0;
124
125  template <unsigned int Tother_degree>
126  void GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
127                        const geometry::tSplineCurve<Tdimension, TElement, Tother_degree> &other_spline) const;
128
129  template <unsigned int Tother_degree>
130  void GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
131                        const geometry::tBezierCurve<Tdimension, TElement, Tother_degree> &bezier_curve) const;
132
133  void GetIntersections(std::vector<typename tShape::tPoint> &intersection_points, std::vector<tParameter> &intersection_parameters,
134                        const tLine<Tdimension, TElement> &line) const;
135
136  const typename tShape::tPoint GetClosestPoint(const typename tShape::tPoint &reference_point) const;
137
138  virtual tSplineCurve &Translate(const math::tVector<Tdimension, TElement> &translation);
139  virtual tSplineCurve &Rotate(const math::tMatrix<Tdimension, Tdimension, TElement> &rotation);
140  virtual tSplineCurve &Transform(const math::tMatrix < Tdimension + 1, Tdimension + 1, TElement > &transformation);
141
142//----------------------------------------------------------------------
143// Private fields and methods
144//----------------------------------------------------------------------
145private:
146
147  std::vector<typename tShape::tPoint> control_points;
148
149  virtual void UpdateBoundingBox(typename tShape::tBoundingBox &bounding_box) const;
150  virtual void UpdateCenterOfGravity(typename tShape::tPoint &center_of_gravity) const;
151
152};
153
154//----------------------------------------------------------------------
155// End of namespace declaration
156//----------------------------------------------------------------------
157}
158}
159
160
161#include "rrlib/geometry/curves/tSplineCurve.hpp"
162
163#endif
Note: See TracBrowser for help on using the repository browser.