Gazebo Math

API Reference

7.4.0
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#include <gz/utils/ImplPtr.hh>
26
27namespace gz
28{
29 namespace math
30 {
31 // Inline bracket to help doxygen filtering.
32 inline namespace GZ_MATH_VERSION_NAMESPACE {
33 //
34 // Forward declare private classes
35 class ControlPoint;
36
39 class GZ_MATH_VISIBLE Spline
40 {
42 public: Spline();
43
48 public: void Tension(double _t);
49
52 public: double Tension() const;
53
56 public: double ArcLength() const;
57
62 public: double ArcLength(const double _t) const;
63
69 public: double ArcLength(const unsigned int _index,
70 const double _t) const;
71
75 public: void AddPoint(const Vector3d &_p);
76
81 public: void AddPoint(const Vector3d &_p, const Vector3d &_t);
82
88 private: void AddPoint(const ControlPoint &_cp, const bool _fixed);
89
95 public: Vector3d Point(const unsigned int _index) const;
96
102 public: Vector3d Tangent(const unsigned int _index) const;
103
110 public: Vector3d MthDerivative(const unsigned int _index,
111 const unsigned int _mth) const;
112
115 public: size_t PointCount() const;
116
118 public: void Clear();
119
125 public: bool UpdatePoint(const unsigned int _index,
126 const Vector3d &_p);
127
134 public: bool UpdatePoint(const unsigned int _index,
135 const Vector3d &_p,
136 const Vector3d &_t);
137
144 private: bool UpdatePoint(const unsigned int _index,
145 const ControlPoint &_cp,
146 const bool _fixed);
147
157 public: Vector3d Interpolate(const double _t) const;
158
169 public: Vector3d Interpolate(const unsigned int _fromIndex,
170 const double _t) const;
171
180 public: Vector3d InterpolateTangent(const double _t) const;
181
192 public: Vector3d InterpolateTangent(const unsigned int _fromIndex,
193 const double _t) const;
194
201 public: Vector3d InterpolateMthDerivative(const unsigned int _mth,
202 const double _1) const;
203
214 public: Vector3d InterpolateMthDerivative(const unsigned int _fromIndex,
215 const unsigned int _mth,
216 const double _s) const;
217
232 public: void AutoCalculate(bool _autoCalc);
233
238 public: void RecalcTangents();
239
241 private: void Rebuild();
242
252 private: bool MapToSegment(const double _t,
253 unsigned int &_index,
254 double &_fraction) const;
255
258 GZ_UTILS_IMPL_PTR(dataPtr)
259 };
260 }
261 }
262}
263#endif