class mrpt::math::CSplineInterpolator1D

A (persistent) sequence of (x,y) coordinates, allowing queries of intermediate points through spline interpolation, where possible.

This class internally relies on mrpt::math::spline. Optionally the y coordinate can be set as wrapped in ]-pi,pi]. For querying interpolated points, see sa mrpt::math::spline, mrpt::poses::CPose3DInterpolator

#include <mrpt/math/CSplineInterpolator1D.h>

class CSplineInterpolator1D: public mrpt::serialization::CSerializable
{
public:
    // construction

    template <class VECTOR>
    CSplineInterpolator1D(
        const VECTOR& initial_x,
        const VECTOR& initial_y,
        bool wrap2pi = false
        );

    CSplineInterpolator1D(bool wrap2pi = false);

    //
methods

    void setWrap2pi(bool wrap);
    bool getWrap2pi();

    template <class VECTOR>
    void setXY(
        const VECTOR& x,
        const VECTOR& y,
        bool clearPreviousContent = true
        );

    void appendXY(double x, double y);
    void clear();
    double& query(double x, double& y, bool& out_valid) const;

    template <class VECTOR1, class VECTOR2>
    bool queryVector(const VECTOR1& x, VECTOR2& out_y) const;
};

Construction

template <class VECTOR>
CSplineInterpolator1D(
    const VECTOR& initial_x,
    const VECTOR& initial_y,
    bool wrap2pi = false
    )

Constructor with optional initial values.

CSplineInterpolator1D(bool wrap2pi = false)

Constructor.

Methods

void setWrap2pi(bool wrap)

If set to true, the interpolated data will be wrapped to ]-pi,pi].

bool getWrap2pi()

Return the wrap property.

template <class VECTOR>
void setXY(
    const VECTOR& x,
    const VECTOR& y,
    bool clearPreviousContent = true
    )

Set all the data at once .

The vectors must have the same length.

void appendXY(double x, double y)

Append a new point:

void clear()

Clears all stored points.

double& query(double x, double& y, bool& out_valid) const

Query an interpolation of the curve at some “x”.

The result is stored in “y”. If the “x” point is out of range, “valid_out” is set to false.

Returns:

A reference to “y”

See also:

queryVector

template <class VECTOR1, class VECTOR2>
bool queryVector(
    const VECTOR1& x,
    VECTOR2& out_y
    ) const

As query, but for a whole vector at once.

Returns:

false if there is at least one value that couldn’t be interpolated (in this case the output is indeterminate).

See also:

query