9 #ifndef CSplineInterpolator1D_H 10 #define CSplineInterpolator1D_H 42 template <
class VECTOR>
44 const VECTOR &initial_x,
45 const VECTOR &initial_y,
46 bool wrap2pi =
false ) : m_wrap2pi(wrap2pi)
48 setXY(initial_x, initial_y);
63 template <
class VECTOR>
64 void setXY(
const VECTOR &
x,
const VECTOR &
y,
bool clearPreviousContent =
true )
67 if (clearPreviousContent) m_x2y.clear();
69 const size_t n =
size_t(
x.size());
70 for (
size_t i=0;i<
n;i++)
76 void appendXY(
double x,
double y );
86 double &query(
double x,
double &
y,
bool &out_valid )
const;
92 template <
class VECTOR1,
class VECTOR2>
95 const size_t n = size_t(
x.size());
97 bool valid, anyValid=
false;
98 for (
size_t i =0;i<
n;i++)
100 query(
x[i], out_y[i], valid );
101 if (valid) anyValid=
true;
#define ASSERT_EQUAL_(__A, __B)
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".
std::map< double, double > m_x2y
The placeholders for the data.
A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline ...
#define DEFINE_SERIALIZABLE_PRE_CUSTOM_BASE(class_name, base_name)
This declaration must be inserted in all CSerializable classes definition, before the class declarati...
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...
#define DEFINE_SERIALIZABLE_POST_CUSTOM_BASE(class_name, base_name)
void setXY(const VECTOR &x, const VECTOR &y, bool clearPreviousContent=true)
Set all the data at once .
bool getWrap2pi()
Return the wrap property.
CSplineInterpolator1D(const VECTOR &initial_x, const VECTOR &initial_y, bool wrap2pi=false)
Constructor with optional initial values.