All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Spline.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2014 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_SPLINE_HH_
20 #define _IGNITION_SPLINE_HH_
21 
22 #include <vector>
23 
24 #include <ignition/math/Helpers.hh>
26 #include <ignition/math/Matrix4.hh>
27 #include <ignition/math/Vector3.hh>
28 
29 namespace ignition
30 {
31  namespace math
32  {
36  {
38  public: Spline();
39 
41  public: ~Spline();
42 
46  public: void Tension(double _t);
47 
50  public: double Tension() const;
51 
54  public: void AddPoint(const Vector3d &_pt);
55 
61  public: Vector3d Point(unsigned int _index) const;
62 
65  public: unsigned int PointCount() const;
66 
70  public: Vector3d Tangent(unsigned int _index) const;
71 
73  public: void Clear();
74 
81  public: void UpdatePoint(unsigned int _index, const Vector3d &_value);
82 
86  public: Vector3d Interpolate(double _t) const;
87 
94  public: Vector3d Interpolate(unsigned int _fromIndex, double _t) const;
95 
110  public: void AutoCalculate(bool _autoCalc);
111 
116  public: void RecalcTangents();
117 
120  protected: bool autoCalc;
121 
123  protected: std::vector<Vector3d> points;
124 
126  protected: std::vector<Vector3d> tangents;
127 
129  protected: Matrix4d coeffs;
130 
132  protected: double tension;
133  };
134  }
135 }
136 #endif
std::vector< Vector3d > points
control points
Definition: Spline.hh:123
Matrix4d coeffs
Matrix of coefficients.
Definition: Spline.hh:129
#define IGNITION_VISIBLE
Use to represent "symbol visible" if supported.
Definition: Helpers.hh:346
Splines.
Definition: Spline.hh:35
bool autoCalc
when true, the tangents are recalculated when the control point change
Definition: Spline.hh:120
std::vector< Vector3d > tangents
tangents
Definition: Spline.hh:126
double tension
Tension of 0 = Catmull-Rom spline, otherwise a Cardinal spline.
Definition: Spline.hh:132