Gazebo Math

API Reference

6.15.1
gz/math/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 GZ_MATH_SPLINE_HH_
20 #define GZ_MATH_SPLINE_HH_
21 
22 #include <gz/math/Helpers.hh>
23 #include <gz/math/Vector3.hh>
24 #include <gz/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
void RecalcTangents()
Recalculates the tangents associated with this spline.
Splines.
Definition: gz/math/Spline.hh:39
double Tension() const
Gets the tension value.
Definition: gz/math/AdditivelySeparableScalarField3.hh:27
void AutoCalculate(bool _autoCalc)
Tells the spline whether it should automatically calculate tangents on demand as points are added.
Vector3d Tangent(const unsigned int _index) const
Gets the tangent value for one of the control points of the spline.
Vector3d Point(const unsigned int _index) const
Gets the value for one of the control points of the spline.
size_t PointCount() const
Gets the number of control points in the spline.
void AddPoint(const Vector3d &_p)
Adds a single control point to the end of the spline.
double ArcLength() const
Gets spline arc length.
The Vector3 class represents the generic vector containing 3 elements. Since it's commonly used to ke...
Definition: gz/math/Vector3.hh:41
Vector3d InterpolateMthDerivative(const unsigned int _mth, const double _1) const
Interpolates the mth derivative of the spline at parameter value _t.
void Clear()
Clears all the points in the spline.
bool UpdatePoint(const unsigned int _index, const Vector3d &_p)
Updates a single control point value in the spline, keeping its tangent.
Vector3d InterpolateTangent(const double _t) const
Interpolates a tangent on the spline at parameter value _t.
Vector3d Interpolate(const double _t) const
Interpolates a point on the spline at parameter value _t.
Vector3d MthDerivative(const unsigned int _index, const unsigned int _mth) const
Gets the mth derivative for one of the control points of the spline.