Ignition Math

API Reference

6.8.0
Spline.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 // Note: Originally cribbed from Ogre3d. Modified to implement Cardinal
18 // spline and catmull-rom spline
19 #ifndef IGNITION_MATH_SPLINE_HH_
20 #define IGNITION_MATH_SPLINE_HH_
21 
22 #include <ignition/math/Helpers.hh>
23 #include <ignition/math/Vector3.hh>
24 #include <ignition/math/config.hh>
25 
26 namespace ignition
27 {
28  namespace math
29  {
30  // Inline bracket to help doxygen filtering.
31  inline namespace IGNITION_MATH_VERSION_NAMESPACE {
32  //
33  // Forward declare private classes
34  class ControlPoint;
35  class SplinePrivate;
36 
39  class IGNITION_MATH_VISIBLE Spline
40  {
42  public: Spline();
43 
45  public: ~Spline();
46 
51  public: void Tension(double _t);
52 
55  public: double Tension() const;
56 
59  public: double ArcLength() const;
60 
65  public: double ArcLength(const double _t) const;
66 
72  public: double ArcLength(const unsigned int _index,
73  const double _t) const;
74 
78  public: void AddPoint(const Vector3d &_p);
79 
84  public: void AddPoint(const Vector3d &_p, const Vector3d &_t);
85 
91  private: void AddPoint(const ControlPoint &_cp, const bool _fixed);
92 
98  public: Vector3d Point(const unsigned int _index) const;
99 
105  public: Vector3d Tangent(const unsigned int _index) const;
106 
113  public: Vector3d MthDerivative(const unsigned int _index,
114  const unsigned int _mth) const;
115 
118  public: size_t PointCount() const;
119 
121  public: void Clear();
122 
128  public: bool UpdatePoint(const unsigned int _index,
129  const Vector3d &_p);
130 
137  public: bool UpdatePoint(const unsigned int _index,
138  const Vector3d &_p,
139  const Vector3d &_t);
140 
147  private: bool UpdatePoint(const unsigned int _index,
148  const ControlPoint &_cp,
149  const bool _fixed);
150 
160  public: Vector3d Interpolate(const double _t) const;
161 
172  public: Vector3d Interpolate(const unsigned int _fromIndex,
173  const double _t) const;
174 
183  public: Vector3d InterpolateTangent(const double _t) const;
184 
195  public: Vector3d InterpolateTangent(const unsigned int _fromIndex,
196  const double _t) const;
197 
204  public: Vector3d InterpolateMthDerivative(const unsigned int _mth,
205  const double _1) const;
206 
217  public: Vector3d InterpolateMthDerivative(const unsigned int _fromIndex,
218  const unsigned int _mth,
219  const double _s) const;
220 
235  public: void AutoCalculate(bool _autoCalc);
236 
241  public: void RecalcTangents();
242 
244  private: void Rebuild();
245 
255  private: bool MapToSegment(const double _t,
256  unsigned int &_index,
257  double &_fraction) const;
258 
261  private: SplinePrivate *dataPtr;
262  };
263  }
264  }
265 }
266 #endif
Splines.
Definition: Spline.hh:39
The Vector3 class represents the generic vector containing 3 elements. Since it&#39;s commonly used to ke...
Definition: Vector3.hh:41
Definition: Angle.hh:42