All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Spline.hh
Go to the documentation of this file.
1 /*
2  * Copyright 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 _SPLINE_HH_
20 #define _SPLINE_HH_
21 
22 #include <vector>
23 
24 #include "gazebo/math/Vector3.hh"
25 #include "gazebo/math/Matrix4.hh"
26 
27 namespace gazebo
28 {
29  namespace math
30  {
33 
36  class Spline
37  {
39  public: Spline();
40 
42  public: ~Spline();
43 
47  public: void SetTension(double _t);
48 
51  public: double GetTension() const;
52 
55  public: void AddPoint(const Vector3 &_pt);
56 
61  public: Vector3 GetPoint(unsigned int _index) const;
62 
65  public: unsigned int GetPointCount() const;
66 
69  public: Vector3 GetTangent(unsigned int _index) const;
70 
72  public: void Clear();
73 
79  public: void UpdatePoint(unsigned int _index, const Vector3 &_value);
80 
84  public: Vector3 Interpolate(double _t) const;
85 
91  public: Vector3 Interpolate(unsigned int _fromIndex, double _t) const;
92 
93 
108  public: void SetAutoCalculate(bool _autoCalc);
109 
114  public: void RecalcTangents();
115 
118  protected: bool autoCalc;
119 
121  protected: std::vector<Vector3> points;
122 
124  protected: std::vector<Vector3> tangents;
125 
127  protected: Matrix4 coeffs;
128 
130  protected: double tension;
131  };
133  }
134 }
135 #endif