Program Listing for File polynom.hpp

Return to documentation for file (include/bitbots_splines/polynom.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_POLYNOM_H_
#define BITBOTS_SPLINES_INCLUDE_BITBOTS_SPLINES_POLYNOM_H_

#include <cstdlib>
#include <iostream>
#include <vector>

namespace bitbots_splines {

class Polynom {
 public:
  Polynom();
  explicit Polynom(unsigned int degree);

  const std::vector<double> &getCoefs() const;
  std::vector<double> &getCoefs();

  const double &operator()(size_t index) const;
  double &operator()(size_t index);

  size_t degree() const;

  double pos(double x) const;
  double vel(double x) const;
  double acc(double x) const;
  double jerk(double x) const;

  void operator*=(double coef);
  void operator+=(const Polynom &p);

  void shift(double delta);

 private:
  std::vector<double> coefs_;
};

std::ostream &operator<<(std::ostream &os, const Polynom &p);

}  // namespace bitbots_splines

#endif