Program Listing for File spline.hpp
↰ Return to documentation for file (include/bitbots_splines/spline.hpp)
/*
This code is largely based on the original code by Quentin "Leph" Rouxel and Team Rhoban.
The original files can be found at:
https://github.com/Rhoban/model/
*/
#ifndef BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_SPLINE_HPP_
#define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_SPLINE_HPP_
#include <iostream>
#include <vector>
#include "polynom.hpp"
namespace bitbots_splines {
class Spline {
 public:
  struct SplineT {
    Polynom polynom;
    double min;
    double max;
  };
  double pos(double t) const;
  double vel(double t) const;
  double acc(double t) const;
  double jerk(double t) const;
  double posMod(double t) const;
  double velMod(double t) const;
  double accMod(double t) const;
  double jerkMod(double t) const;
  double min() const;
  double max() const;
  void exportData(std::ostream &os) const;
  void importData(std::istream &is);
  size_t size() const;
  const SplineT &part(size_t index) const;
  void addPart(const Polynom &poly, double min, double max);
  void copyData(const Spline &sp);
 protected:
  std::vector<SplineT> splines_;
  virtual void importCallBack();
 private:
  double interpolation(double x, double (Polynom::*func)(double) const) const;
  double interpolationMod(double x, double (Polynom::*func)(double) const) const;
};
}  // namespace bitbots_splines
#endif