9 #ifndef CSplineInterpolator1D_H 10 #define CSplineInterpolator1D_H 41 template <
class VECTOR>
43 const VECTOR& initial_x,
const VECTOR& initial_y,
bool wrap2pi =
false)
46 setXY(initial_x, initial_y);
59 template <
class VECTOR>
61 const VECTOR&
x,
const VECTOR&
y,
bool clearPreviousContent =
true)
64 if (clearPreviousContent)
m_x2y.clear();
66 const size_t n =
size_t(
x.size());
67 for (
size_t i = 0; i <
n; i++)
m_x2y[
x[i]] =
y[i];
82 double&
query(
double x,
double&
y,
bool& out_valid)
const;
89 template <
class VECTOR1,
class VECTOR2>
92 const size_t n = size_t(
x.size());
94 bool valid, anyValid =
false;
95 for (
size_t i = 0; i <
n; i++)
97 query(
x[i], out_y[i], valid);
98 if (valid) anyValid =
true;
#define ASSERT_EQUAL_(__A, __B)
std::map< double, double > m_x2y
The placeholders for the data.
The virtual base class which provides a unified interface for all persistent objects in MRPT...
void clear()
Clears all stored points.
bool m_wrap2pi
Whether to wrap "y".
void appendXY(double x, double y)
Append a new point:
A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline ...
void setWrap2pi(bool wrap)
If set to true, the interpolated data will be wrapped to ]-pi,pi].
bool queryVector(const VECTOR1 &x, VECTOR2 &out_y) const
As query, but for a whole vector at once.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
void setXY(const VECTOR &x, const VECTOR &y, bool clearPreviousContent=true)
Set all the data at once .
bool getWrap2pi()
Return the wrap property.
double & query(double x, double &y, bool &out_valid) const
Query an interpolation of the curve at some "x".
CSplineInterpolator1D(const VECTOR &initial_x, const VECTOR &initial_y, bool wrap2pi=false)
Constructor with optional initial values.