Commit 7cca5327 authored by stonneau's avatar stonneau

more cleaning

parent fcd529d6
......@@ -63,7 +63,6 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/* Constructors - destructors */
/*Operations*/
public:
public:
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
......@@ -100,8 +99,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Operations*/
/*Helpers*/
virtual time_t MinBound() const{return minBound_;}
virtual time_t MaxBound() const{return minBound_;}
virtual time_t min() const{return minBound_;}
virtual time_t max() const{return maxBound_;}
/*Helpers*/
public:
......
......@@ -22,64 +22,66 @@
namespace spline
{
/// \class CubicFunction
/// \brief Represents a cubic spline defined on the interval
/// [tBegin, tEnd]. It follows the equation
/// 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
, typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
{
/// \class CubicFunction
/// \brief Represents a cubic spline defined on the interval
/// [tBegin, tEnd]. It follows the equation
/// 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
, typename Point= Eigen::Matrix<Numeric, Dim, 1> >
struct cubic_function : public curve_abc<Time, Numeric, Dim, Safe, Point>
{
typedef Point point_t;
typedef Time time_t;
typedef Numeric num_t;
/* Constructors - destructors */
public:
///\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)
:a_(a), b_(b), c_(c), d_(d), t_min_(min), t_max_(max)
///\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)
: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
~cubic_function()
{
// NOTHING
}
///\brief Destructor
~cubic_function()
{
// NOTHING
}
private:
//cubic_function(const cubic_function&);
//cubic_function& operator=(const cubic_function&);
cubic_function(const cubic_function&);
cubic_function& operator=(const cubic_function&);
/* Constructors - destructors */
/*Operations*/
public:
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
/// \param return : the value x(t)
virtual point_t operator()(time_t t) const
{
if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");}
time_t const dt (t-t_min_);
return a_+ b_ * dt + c_ * dt*dt + d_ * dt*dt*dt;
}
/// \brief Evaluation of the cubic spline at time t.
/// \param t : the time when to evaluate the spine
/// \param return : the value x(t)
virtual point_t operator()(time_t t) const
{
if((t < t_min_ || t > t_max_) && Safe){ throw std::out_of_range("TODO");}
time_t const dt (t-t_min_);
return a_+ b_ * dt + c_ * dt*dt + d_ * dt*dt*dt;
}
/*Operations*/
/*Helpers*/
public:
num_t virtual MinBound() const {return t_min_;}
num_t virtual MaxBound() const {return t_max_;}
/// \brief Returns the minimum time for wich curve is defined
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*/
/*Attributes*/
public:
const point_t a_, b_, c_ ,d_;
const time_t t_min_, t_max_;
const point_t a_, b_, c_ ,d_;
const time_t t_min_, t_max_;
/*Attributes*/
}; //class CubicFunction
}
......
......@@ -46,8 +46,11 @@ struct curve_abc : std::unary_function<Time, Point>
/*Operations*/
/*Helpers*/
virtual time_t MinBound() const = 0;
virtual time_t MaxBound() const = 0;
public:
/// \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*/
};
......
......@@ -27,9 +27,6 @@
#include <functional>
#include <vector>
#include <Eigen/StdVector>
#include <iostream>
namespace spline
{
......@@ -162,8 +159,8 @@ struct exact_cubic : public curve_abc<Time, Numeric, Dim, Safe, Point>
/*Helpers*/
public:
num_t virtual MinBound() const{return subSplines_.front()->t_min_;}
num_t virtual MaxBound() const{return subSplines_.back()->t_max_;}
num_t virtual min() const{return subSplines_.front()->t_min_;}
num_t virtual max() const{return subSplines_.back()->t_max_;}
/*Helpers*/
/*Attributes*/
......
......@@ -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";
}
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*/
......@@ -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";
}
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*/
......@@ -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";
}
if(exactCubic.MaxBound() != 1)
if(exactCubic.max() != 1)
{
error = true;
std::cout << "Evaluation of exactCubic error, MaxBound should be equal to 1\n";
}
if(exactCubic.MinBound() != 0)
if(exactCubic.min() != 0)
{
error = true;
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