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 
25 namespace ignition
26 {
27  namespace math
28  {
29  // Forward declare private classes
30  class ControlPoint;
31  class SplinePrivate;
32 
36  {
38  public: Spline();
39 
41  public: ~Spline();
42 
47  public: void Tension(double _t);
48 
51  public: double Tension() const;
52 
55  public: double ArcLength() const;
56 
61  public: double ArcLength(const double _t) const;
62 
68  public: double ArcLength(const unsigned int _index,
69  const double _t) const;
70 
74  public: void AddPoint(const Vector3d &_p);
75 
80  public: void AddPoint(const Vector3d &_p, const Vector3d &_t);
81 
87  private: void AddPoint(const ControlPoint &_cp, const bool _fixed);
88 
94  public: Vector3d Point(const unsigned int _index) const;
95 
101  public: Vector3d Tangent(const unsigned int _index) const;
102 
109  public: Vector3d MthDerivative(const unsigned int _index,
110  const unsigned int _mth) const;
111 
114  public: size_t PointCount() const;
115 
117  public: void Clear();
118 
124  public: bool UpdatePoint(const unsigned int _index,
125  const Vector3d &_p);
126 
133  public: bool UpdatePoint(const unsigned int _index,
134  const Vector3d &_p,
135  const Vector3d &_t);
136 
143  private: bool UpdatePoint(const unsigned int _index,
144  const ControlPoint &_cp,
145  const bool _fixed);
146 
156  public: Vector3d Interpolate(const double _t) const;
157 
168  public: Vector3d Interpolate(const unsigned int _fromIndex,
169  const double _t) const;
170 
179  public: Vector3d InterpolateTangent(const double _t) const;
180 
191  public: Vector3d InterpolateTangent(const unsigned int _fromIndex,
192  const double _t) const;
193 
200  public: Vector3d InterpolateMthDerivative(const unsigned int _mth,
201  const double _1) const;
202 
213  public: Vector3d InterpolateMthDerivative(const unsigned int _fromIndex,
214  const unsigned int _mth,
215  const double _s) const;
216 
231  public: void AutoCalculate(bool _autoCalc);
232 
237  public: void RecalcTangents();
238 
240  private: void Rebuild();
241 
251  private: bool MapToSegment(const double _t,
252  unsigned int &_index,
253  double &_fraction) const;
254 
257  private: SplinePrivate *dataPtr;
258  };
259  }
260 }
261 #endif
Private data for Spline class.
Definition: SplinePrivate.hh:175
Splines.
Definition: Spline.hh:35
Control point representation for polynomial interpolation, defined in terms of arbitrary m derivative...
Definition: SplinePrivate.hh:33
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: System.hh:59
Definition: Angle.hh:38