37 template <
class VECTOR>
39 const VECTOR& initial_x,
const VECTOR& initial_y,
bool wrap2pi =
false)
42 setXY(initial_x, initial_y);
55 template <
class VECTOR>
57 const VECTOR&
x,
const VECTOR&
y,
bool clearPreviousContent =
true)
60 if (clearPreviousContent)
m_x2y.clear();
62 const size_t n = size_t(
x.size());
63 for (
size_t i = 0; i <
n; i++)
m_x2y[
x[i]] =
y[i];
78 double&
query(
double x,
double&
y,
bool& out_valid)
const;
85 template <
class VECTOR1,
class VECTOR2>
88 const size_t n = size_t(
x.size());
90 bool valid, anyValid =
false;
91 for (
size_t i = 0; i <
n; i++)
93 query(
x[i], out_y[i], valid);
94 if (valid) anyValid =
true;
std::map< double, double > m_x2y
The placeholders for the data.
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 ...
This base provides a set of functions for maths stuff.
#define ASSERT_EQUAL_(__A, __B)
Assert comparing two values, reporting their actual values upon failure.
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.
#define DEFINE_SERIALIZABLE(class_name)
This declaration must be inserted in all CSerializable classes definition, within the class declarati...
The virtual base class which provides a unified interface for all persistent objects in MRPT...
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.