Commit 7cca5327 authored by stonneau's avatar stonneau
Browse files

more cleaning

parent fcd529d6
...@@ -63,7 +63,6 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> ...@@ -63,7 +63,6 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/* Constructors - destructors */ /* Constructors - destructors */
/*Operations*/ /*Operations*/
public:
public: public:
/// \brief Evaluation of the cubic spline at time t. /// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine /// \param t : the time when to evaluate the spine
...@@ -100,8 +99,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> ...@@ -100,8 +99,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Operations*/ /*Operations*/
/*Helpers*/ /*Helpers*/
virtual time_t MinBound() const{return minBound_;} virtual time_t min() const{return minBound_;}
virtual time_t MaxBound() const{return minBound_;} virtual time_t max() const{return maxBound_;}
/*Helpers*/ /*Helpers*/
public: public:
......
...@@ -22,64 +22,66 @@ ...@@ -22,64 +22,66 @@
namespace spline namespace spline
{ {
/// \class CubicFunction /// \class CubicFunction
/// \brief Represents a cubic spline defined on the interval /// \brief Represents a cubic spline defined on the interval
/// [tBegin, tEnd]. It follows the equation /// [tBegin, tEnd]. It follows the equation
/// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3 /// x(t) = a + b(t - t_min_) + c(t - t_min_)^2 + d(t - t_min_)^3
/// ///
template<typename Time= double, typename Numeric=Time, int Dim=3, bool Safe=false template<typename Time= double, typename Numeric=Time, int Dim=3, bool Safe=false
, typename Point= Eigen::Matrix<Numeric, Dim, 1> > , typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point> struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
{ {
typedef Point point_t; typedef Point point_t;
typedef Time time_t; typedef Time time_t;
typedef Numeric num_t; typedef Numeric num_t;
/* Constructors - destructors */ /* Constructors - destructors */
public: public:
///\brief Constructor ///\brief Constructor
cubic_function(point_t const& a, point_t const& b, point_t const& c, point_t const &d, time_t min, time_t max) cubic_function(point_t const& a, point_t const& b, point_t const& c, point_t const &d, time_t min, time_t max)
:a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max) :a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max)
{
if(t_min_ >= t_max_ & Safe)
{ {
if(t_min_ >= t_max_ & Safe) std::out_of_range("TODO");
{
std::out_of_range("TODO");
}
} }
}
///\brief Destructor ///\brief Destructor
~cubic_function() ~cubic_function()
{ {
// NOTHING // NOTHING
} }
private: private:
//cubic_function(const cubic_function&); cubic_function(const cubic_function&);
//cubic_function& operator=(const cubic_function&); cubic_function& operator=(const cubic_function&);
/* Constructors - destructors */ /* Constructors - destructors */
/*Operations*/ /*Operations*/
public: public:
/// \brief Evaluation of the cubic spline at time t. /// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine /// \param t : the time when to evaluate the spine
/// \param return : the value x(t) /// \param return : the value x(t)
virtual point_t operator()(time_t t) const virtual point_t operator()(time_t t) const
{ {
if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");} if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");}
time_t const dt (t-t_min_); time_t const dt (t-t_min_);
return a_+ b_ * dt + c_ * dt*dt + d_ * dt*dt*dt; return a_+ b_ * dt + c_ * dt*dt + d_ * dt*dt*dt;
} }
/*Operations*/ /*Operations*/
/*Helpers*/ /*Helpers*/
public: public:
num_t virtual MinBound() const {return t_min_;} /// \brief Returns the minimum time for wich curve is defined
num_t virtual MaxBound() const {return t_max_;} num_t virtual min() const {return t_min_;}
/// \brief Returns the maximum time for wich curve is defined
num_t virtual max() const {return t_max_;}
/*Helpers*/ /*Helpers*/
/*Attributes*/ /*Attributes*/
public: public:
const point_t a_, b_, c_ ,d_; const point_t a_, b_, c_ ,d_;
const time_t t_min_, t_max_; const time_t t_min_, t_max_;
/*Attributes*/ /*Attributes*/
}; //class CubicFunction }; //class CubicFunction
} }
......
...@@ -46,8 +46,11 @@ struct curve_abc : std::unary_function<Time, Point> ...@@ -46,8 +46,11 @@ struct curve_abc : std::unary_function<Time, Point>
/*Operations*/ /*Operations*/
/*Helpers*/ /*Helpers*/
virtual time_t MinBound() const = 0; public:
virtual time_t MaxBound() const = 0; /// \brief Returns the minimum time for wich curve is defined
virtual time_t min() const = 0;
/// \brief Returns the maximum time for wich curve is defined
virtual time_t max() const = 0;
/*Helpers*/ /*Helpers*/
}; };
......
...@@ -27,9 +27,6 @@ ...@@ -27,9 +27,6 @@
#include <functional> #include <functional>
#include <vector> #include <vector>
#include <Eigen/StdVector>
#include <iostream>
namespace spline namespace spline
{ {
...@@ -162,8 +159,8 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point> ...@@ -162,8 +159,8 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Helpers*/ /*Helpers*/
public: public:
num_t virtual MinBound() const{return subSplines_.front()->t_min_;} num_t virtual min() const{return subSplines_.front()->t_min_;}
num_t virtual MaxBound() const{return subSplines_.back()->t_max_;} num_t virtual max() const{return subSplines_.back()->t_max_;}
/*Helpers*/ /*Helpers*/
/*Attributes*/ /*Attributes*/
......
...@@ -110,6 +110,16 @@ void CubicFunctionTest(bool& error) ...@@ -110,6 +110,16 @@ void CubicFunctionTest(bool& error)
{ {
std::cout << "Evaluation of cubic cf2 error, 1.1 should be an out of range value\n"; std::cout << "Evaluation of cubic cf2 error, 1.1 should be an out of range value\n";
} }
if(cf.max() != 1)
{
error = true;
std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
}
if(cf.min() != 0)
{
error = true;
std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
}
} }
/*bezier_curve Function tests*/ /*bezier_curve Function tests*/
...@@ -180,6 +190,16 @@ void BezierCurveTest(bool& error) ...@@ -180,6 +190,16 @@ void BezierCurveTest(bool& error)
{ {
std::cout << "Evaluation of bezier cf error, 1.1 should be an out of range value\n"; std::cout << "Evaluation of bezier cf error, 1.1 should be an out of range value\n";
} }
if(cf.max() != 1)
{
error = true;
std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
}
if(cf.min() != 0)
{
error = true;
std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
}
} }
/*Exact Cubic Function tests*/ /*Exact Cubic Function tests*/
...@@ -215,12 +235,12 @@ void ExactCubicNoErrorTest(bool& error) ...@@ -215,12 +235,12 @@ void ExactCubicNoErrorTest(bool& error)
{ {
std::cout << "Evaluation of exactCubic cf error, 1.2 should be an out of range value\n"; std::cout << "Evaluation of exactCubic cf error, 1.2 should be an out of range value\n";
} }
if(exactCubic.MaxBound() != 1) if(exactCubic.max() != 1)
{ {
error = true; error = true;
std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n"; std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
} }
if(exactCubic.MinBound() != 0) if(exactCubic.min() != 0)
{ {
error = true; error = true;
std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n"; std::cout << "Evaluation of exactCubic error, MinBound should be equal to 1\n";
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment