Gazebo Math

API Reference

8.0.0
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::math
28{
29 // Inline bracket to help doxygen filtering.
30 inline namespace GZ_MATH_VERSION_NAMESPACE {
31 //
32 // Forward declare private classes
33 class ControlPoint;
34
38 {
40 public: Spline();
41
46 public: void Tension(double _t);
47
50 public: double Tension() const;
51
54 public: double ArcLength() const;
55
60 public: double ArcLength(const double _t) const;
61
67 public: double ArcLength(const unsigned int _index,
68 const double _t) const;
69
73 public: void AddPoint(const Vector3d &_p);
74
79 public: void AddPoint(const Vector3d &_p, const Vector3d &_t);
80
86 private: void AddPoint(const ControlPoint &_cp, const bool _fixed);
87
93 public: Vector3d Point(const unsigned int _index) const;
94
100 public: Vector3d Tangent(const unsigned int _index) const;
101
108 public: Vector3d MthDerivative(const unsigned int _index,
109 const unsigned int _mth) const;
110
113 public: size_t PointCount() const;
114
116 public: void Clear();
117
123 public: bool UpdatePoint(const unsigned int _index,
124 const Vector3d &_p);
125
132 public: bool UpdatePoint(const unsigned int _index,
133 const Vector3d &_p,
134 const Vector3d &_t);
135
142 private: bool UpdatePoint(const unsigned int _index,
143 const ControlPoint &_cp,
144 const bool _fixed);
145
155 public: Vector3d Interpolate(const double _t) const;
156
167 public: Vector3d Interpolate(const unsigned int _fromIndex,
168 const double _t) const;
169
178 public: Vector3d InterpolateTangent(const double _t) const;
179
190 public: Vector3d InterpolateTangent(const unsigned int _fromIndex,
191 const double _t) const;
192
199 public: Vector3d InterpolateMthDerivative(const unsigned int _mth,
200 const double _1) const;
201
212 public: Vector3d InterpolateMthDerivative(const unsigned int _fromIndex,
213 const unsigned int _mth,
214 const double _s) const;
215
230 public: void AutoCalculate(bool _autoCalc);
231
236 public: void RecalcTangents();
237
239 private: void Rebuild();
240
250 private: bool MapToSegment(const double _t,
251 unsigned int &_index,
252 double &_fraction) const;
253
256 GZ_UTILS_IMPL_PTR(dataPtr)
257 };
258 } // namespace GZ_MATH_VERSION_NAMESPACE
259} // namespace gz::math
260#endif // GZ_MATH_SPLINE_HH_