Loading...
Searching...
No Matches
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 IGNITION_MATH_SPLINE_HH_
20#define IGNITION_MATH_SPLINE_HH_
21
24#include <ignition/math/config.hh>
25
26namespace ignition
27{
28 namespace math
29 {
30 inline namespace IGNITION_MATH_VERSION_NAMESPACE
31 {
32 // Forward declare private classes
33 class ControlPoint;
34 class SplinePrivate;
35
38 class IGNITION_MATH_VISIBLE Spline
39 {
41 public: Spline();
42
44 public: ~Spline();
45
50 public: void Tension(double _t);
51
54 public: double Tension() const;
55
58 public: double ArcLength() const;
59
64 public: double ArcLength(const double _t) const;
65
71 public: double ArcLength(const unsigned int _index,
72 const double _t) const;
73
77 public: void AddPoint(const Vector3d &_p);
78
83 public: void AddPoint(const Vector3d &_p, const Vector3d &_t);
84
90 private: void AddPoint(const ControlPoint &_cp, const bool _fixed);
91
97 public: Vector3d Point(const unsigned int _index) const;
98
104 public: Vector3d Tangent(const unsigned int _index) const;
105
112 public: Vector3d MthDerivative(const unsigned int _index,
113 const unsigned int _mth) const;
114
117 public: size_t PointCount() const;
118
120 public: void Clear();
121
127 public: bool UpdatePoint(const unsigned int _index,
128 const Vector3d &_p);
129
136 public: bool UpdatePoint(const unsigned int _index,
137 const Vector3d &_p,
138 const Vector3d &_t);
139
146 private: bool UpdatePoint(const unsigned int _index,
147 const ControlPoint &_cp,
148 const bool _fixed);
149
159 public: Vector3d Interpolate(const double _t) const;
160
171 public: Vector3d Interpolate(const unsigned int _fromIndex,
172 const double _t) const;
173
182 public: Vector3d InterpolateTangent(const double _t) const;
183
194 public: Vector3d InterpolateTangent(const unsigned int _fromIndex,
195 const double _t) const;
196
203 public: Vector3d InterpolateMthDerivative(const unsigned int _mth,
204 const double _1) const;
205
216 public: Vector3d InterpolateMthDerivative(const unsigned int _fromIndex,
217 const unsigned int _mth,
218 const double _s) const;
219
234 public: void AutoCalculate(bool _autoCalc);
235
240 public: void RecalcTangents();
241
243 private: void Rebuild();
244
254 private: bool MapToSegment(const double _t,
255 unsigned int &_index,
256 double &_fraction) const;
257
260 private: SplinePrivate *dataPtr;
261 };
262 }
263 }
264}
265#endif
bool UpdatePoint(const unsigned int _index, const Vector3d &_p, const Vector3d &_t)
Updates a single control point in the spline, along with its tangent.
double Tension() const
Gets the tension value.
void AutoCalculate(bool _autoCalc)
Tells the spline whether it should automatically calculate tangents on demand as points are added.
double ArcLength(const double _t) const
Gets spline arc length up to a given 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.
Vector3d InterpolateTangent(const unsigned int _fromIndex, const double _t) const
Interpolates the tangent on a segment of the spline at parameter value _t.
void Clear()
Clears all the points in the spline.
void AddPoint(const Vector3d &_p, const Vector3d &_t)
Adds a single control point to the end of the spline with fixed tangent.
bool UpdatePoint(const unsigned int _index, const Vector3d &_p)
Updates a single control point value in the spline, keeping its tangent.
size_t PointCount() const
Gets the number of control points in the spline.
void RecalcTangents()
Recalculates the tangents associated with this spline.
Vector3d Tangent(const unsigned int _index) const
Gets the tangent value for one of the control points of the spline.
void AddPoint(const Vector3d &_p)
Adds a single control point to the end of the spline.
Vector3d InterpolateMthDerivative(const unsigned int _mth, const double _1) const
Interpolates the mth derivative of the spline at parameter value _t.
double ArcLength(const unsigned int _index, const double _t) const
Gets a spline segment arc length.
Vector3d InterpolateMthDerivative(const unsigned int _fromIndex, const unsigned int _mth, const double _s) const
Interpolates the mth derivative of a segment of the spline at parameter value _t.
void Tension(double _t)
Sets the tension parameter.
Vector3d Point(const unsigned int _index) const
Gets the value for one of the control points of the spline.
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.
double ArcLength() const
Gets spline arc length.
Vector3d Interpolate(const unsigned int _fromIndex, const double _t) const
Interpolates a point on a segment of the spline at parameter value _t.
The Vector3 class represents the generic vector containing 3 elements.
Definition Vector3.hh:40
Definition Angle.hh:40