Skip to content
Snippets Groups Projects
Commit 85687ecf authored by Steve T's avatar Steve T
Browse files

[BUG FIX] evalXXX methods do not consider time

parent bf71c76b
No related branches found
No related tags found
1 merge request!9[BUG FIX] evalXXX methods do not consider time
......@@ -141,7 +141,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
virtual point_t operator()(const time_t t) const
{
num_t nT = t / T_;
if(Safe &! (0 <= nT && nT <= 1))
if(Safe &! (0 <= t && t <= T_))
{
throw std::out_of_range("can't evaluate bezier curve, out of range"); // TODO
}
......@@ -166,7 +166,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
+ 3 * pts_[2] * nT * nT * dt
+ pts_[3] * nT * nT *nT);
default :
return mult_T_ * evalHorner(nT);
return evalHorner(t);
break;
}
}
......@@ -227,20 +227,22 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
///
point_t evalBernstein(const Numeric u) const
{
const Numeric t = u/T_;
point_t res = point_t::Zero(Dim);
typename t_point_t::const_iterator pts_it = pts_.begin();
for(typename std::vector<Bern<Numeric> >::const_iterator cit = bernstein_.begin();
cit !=bernstein_.end(); ++cit, ++pts_it)
res += cit->operator()(u) * (*pts_it);
return res;
res += cit->operator()(t) * (*pts_it);
return res*mult_T_;
}
///
/// \brief Evaluates all Bernstein polynomes for a certain degree using horner's scheme
///
point_t evalHorner(const Numeric t) const
point_t evalHorner(const Numeric v) const
{
const Numeric t = v/T_;
typename t_point_t::const_iterator pts_it = pts_.begin();
Numeric u, bc, tn;
u = 1.0 - t;
......@@ -253,7 +255,7 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point>
bc = bc*((num_t)(degree_-i+1))/i;
tmp = (tmp + tn*bc*(*pts_it))*u;
}
return (tmp + tn*t*(*pts_it));
return (tmp + tn*t*(*pts_it))*mult_T_;
}
const t_point_t& waypoints() const {return pts_;}
......
......@@ -181,11 +181,14 @@ void BezierCurveTest(bool& error)
ComparePoints(d, res1, errMsg + "3(1) ", error);
//testing bernstein polynomes
bezier_curve_t cf5(params.begin(), params.end(),2.);
std::string errMsg2("In test BezierCurveTest ; Bernstein polynoms do not evaluate as analytical evaluation");
for(double d = 0.; d <1.; d+=0.1)
for(double d = 0.; d <2.; d+=0.1)
{
ComparePoints( cf3.evalBernstein(d) , cf3 (d), errMsg2, error);
ComparePoints( cf3.evalHorner(d) , cf3 (d), errMsg2, error);
ComparePoints( cf5.evalBernstein(d) , cf5 (d), errMsg2, error);
ComparePoints( cf5.evalHorner(d) , cf5 (d), errMsg2, error);
ComparePoints( cf5.compute_derivate(1).evalBernstein(d) , cf5.compute_derivate(1) (d), errMsg2, error);
ComparePoints( cf5.compute_derivate(1).evalHorner(d) , cf5.compute_derivate(1) (d), errMsg2, error);
}
bool error_in(true);
......
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