Skip to content
Snippets Groups Projects
Commit 750eabc9 authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

polynomial and piecewise_polynomial : remove dim from template and init it...

polynomial and piecewise_polynomial : remove dim from template and init it from the size of the points
parent 9d0f90fb
No related branches found
No related tags found
No related merge requests found
......@@ -236,7 +236,7 @@ namespace curves
}
template<typename Polynomial>
static piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial>
static piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial>
convert_discrete_points_to_polynomial(T_Point points,T_Point points_derivative, t_time_t time_points)
{
if(Safe &! (points.size()>1))
......@@ -250,7 +250,7 @@ namespace curves
if(points.size() != points_derivative.size()){
throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_derivative must have the same size.");
}
piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial> piecewise_res;
piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial> piecewise_res;
for(size_t i = 1 ; i < points.size() ; ++i){
piecewise_res.add_curve(Polynomial(points[i-1],points_derivative[i-1],points[i],points_derivative[i],time_points[i-1],time_points[i]));
......@@ -259,7 +259,7 @@ namespace curves
}
template<typename Polynomial>
static piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial>
static piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial>
convert_discrete_points_to_polynomial(T_Point points,T_Point points_derivative, T_Point points_second_derivative, t_time_t time_points)
{
if(Safe &! (points.size()>1))
......@@ -276,7 +276,7 @@ namespace curves
if(points.size() != points_second_derivative.size()){
throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, points and points_second_derivative must have the same size.");
}
piecewise_curve<Time, Numeric, Dim, Safe, Point, T_Point, Polynomial> piecewise_res;
piecewise_curve<Time, Numeric, Safe, Point, T_Point, Polynomial> piecewise_res;
for(size_t i = 1 ; i < points.size() ; ++i){
piecewise_res.add_curve(Polynomial(points[i-1],points_derivative[i-1],points_second_derivative[i-1],points[i],points_derivative[i],points_second_derivative[i],time_points[i-1],time_points[i]));
......
......@@ -84,6 +84,7 @@ namespace curves
safe_check();
}
/// \brief Constructor.
/// \param zeroOrderCoefficient : an iterator pointing to the first element of a structure containing the coefficients
/// it corresponds to the zero degree coefficient.
......@@ -109,9 +110,11 @@ namespace curves
/// \param max : UPPER bound on interval definition of the spline.
///
polynomial(const Point& init, const Point& end, const time_t min, const time_t max ):
dim_(Dim), degree_(1),
dim_(init.size()), degree_(1),
T_min_(min), T_max_(max)
{
if(init.size() != end.size())
throw std::invalid_argument("init and end points must have the same dimensions.");
t_point_t coeffs;
coeffs.push_back(init);
coeffs.push_back((end-init)/(max-min));
......@@ -130,9 +133,15 @@ namespace curves
/// \param max : UPPER bound on interval definition of the spline.
///
polynomial(const Point& init,const Point& d_init, const Point& end, const Point& d_end,const time_t min, const time_t max ):
dim_(Dim), degree_(3),
dim_(init.size()), degree_(3),
T_min_(min), T_max_(max)
{
if(init.size() != end.size())
throw std::invalid_argument("init and end points must have the same dimensions.");
if(init.size() != d_init.size())
throw std::invalid_argument("init and d_init points must have the same dimensions.");
if(init.size() != d_end.size())
throw std::invalid_argument("init and d_end points must have the same dimensions.");
/* the coefficients [c0 c1 c2 c3] are found by solving the following system of equation
(found from the boundary conditions) :
[1 0 0 0 ] [c0] [ init ]
......@@ -172,9 +181,19 @@ namespace curves
/// \param max : UPPER bound on interval definition of the spline.
///
polynomial(const Point& init,const Point& d_init,const Point& dd_init, const Point& end, const Point& d_end,const Point& dd_end,const time_t min, const time_t max ):
dim_(Dim), degree_(5),
dim_(init.size()), degree_(5),
T_min_(min), T_max_(max)
{
if(init.size() != end.size())
throw std::invalid_argument("init and end points must have the same dimensions.");
if(init.size() != d_init.size())
throw std::invalid_argument("init and d_init points must have the same dimensions.");
if(init.size() != d_end.size())
throw std::invalid_argument("init and d_end points must have the same dimensions.");
if(init.size() != dd_init.size())
throw std::invalid_argument("init and dd_init points must have the same dimensions.");
if(init.size() != dd_end.size())
throw std::invalid_argument("init and dd_end points must have the same dimensions.");
/* the coefficients [c0 c1 c2 c3 c4 c5] are found by solving the following system of equation
(found from the boundary conditions) :
[1 0 0 0 0 0 ] [c0] [ init ]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment