Spline.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2015 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 #include "gazebo/util/system.hh"
27 
28 namespace gazebo
29 {
30  namespace math
31  {
34 
38  {
40  public: Spline();
41 
43  public: ~Spline();
44 
48  public: void SetTension(double _t);
49 
52  public: double GetTension() const;
53 
56  public: void AddPoint(const Vector3 &_pt);
57 
62  public: Vector3 GetPoint(unsigned int _index) const;
63 
66  public: unsigned int GetPointCount() const;
67 
70  public: Vector3 GetTangent(unsigned int _index) const;
71 
73  public: void Clear();
74 
80  public: void UpdatePoint(unsigned int _index, const Vector3 &_value);
81 
85  public: Vector3 Interpolate(double _t) const;
86 
92  public: Vector3 Interpolate(unsigned int _fromIndex, double _t) const;
93 
94 
109  public: void SetAutoCalculate(bool _autoCalc);
110 
115  public: void RecalcTangents();
116 
119  protected: bool autoCalc;
120 
122  protected: std::vector<Vector3> points;
123 
125  protected: std::vector<Vector3> tangents;
126 
128  protected: Matrix4 coeffs;
129 
131  protected: double tension;
132  };
134  }
135 }
136 #endif
std::vector< Vector3 > tangents
tangents
Definition: Spline.hh:125
The Vector3 class represents the generic vector containing 3 elements.
Definition: Vector3.hh:39
A 3x3 matrix class.
Definition: Matrix4.hh:40
std::vector< Vector3 > points
control points
Definition: Spline.hh:122
bool autoCalc
when true, the tangents are recalculated when the control point change
Definition: Spline.hh:119
Splines.
Definition: Spline.hh:37
double tension
Tension of 0 = Catmull-Rom spline, otherwise a Cardinal spline.
Definition: Spline.hh:131
Matrix4 coeffs
Matrix of coefficients.
Definition: Spline.hh:128
#define GZ_MATH_VISIBLE
Definition: system.hh:141