diff --git a/include/curves/bezier_curve.h b/include/curves/bezier_curve.h index d16e9a985be3c45372a4284c0044da29cc4c6477..2e439dcc212fd3cc80b61caf008dde6e140f98a3 100644 --- a/include/curves/bezier_curve.h +++ b/include/curves/bezier_curve.h @@ -268,8 +268,8 @@ struct bezier_curve : public curve_abc<Time, Numeric, Dim, Safe, Point> /// \brief Compute de Casteljau's reduction of the given list of points at time t. /// For the list \f$pts\f$ of N points, compute a new list of points of size N-1 :<br> /// \f$<br>( pts[0]*(1-t)+pts[1], pts[1]*(1-t)+pts[2], ..., pts[0]*(N-2)+pts[N-1] )\f$<br> - /// with t the time when to evaluate bezier curve.<br>\ - /// The new list contains centroid of parameters \f${t,1-t}\f$ of consecutive points in the list. + /// with t the time when to evaluate bezier curve.<br>\ The new list contains centroid of + /// parameters \f${t,1-t}\f$ of consecutive points in the list. /// \param pts : list of points. /// \param u : NORMALIZED time when to evaluate the curve. /// \return reduced list of point (size of pts - 1). diff --git a/include/curves/cubic_hermite_spline.h b/include/curves/cubic_hermite_spline.h index d12c56ccf383b2cff346f5971dd09230e30af077..aab442902c8b9534f3e971aa832cab3860c13ef8 100644 --- a/include/curves/cubic_hermite_spline.h +++ b/include/curves/cubic_hermite_spline.h @@ -39,7 +39,6 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> typedef std::vector< pair_point_tangent_t ,Eigen::aligned_allocator<Point> > t_pair_point_tangent_t; typedef std::vector<Time> vector_time_t; typedef Numeric num_t; - typedef int Index; /*Attributes*/ public: @@ -61,7 +60,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> /// Number of control points (pairs). std::size_t size_; /// Degree (Cubic so degree 3) - const std::size_t degree_ = 3; + static const std::size_t degree_ = 3; /*Attributes*/ public: @@ -164,12 +163,12 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> /// \brief Get number of control points contained in the trajectory. /// \return number of control points. /// - Index size() const { return size_; } + std::size_t size() const { return size_; } /// \brief Get number of intervals (subsplines) contained in the trajectory. /// \return number of intervals (subsplines). /// - Index numIntervals() const { return size()-1; } + std::size_t numIntervals() const { return size()-1; } /// \brief Evaluate value of cubic hermite spline or its derivate at specified order at time \f$t\f$. @@ -186,7 +185,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> /// Point evalCubicHermiteSpline(const Numeric t, std::size_t order_derivative) const { - const Index id = findInterval(t); + const std::size_t id = findInterval(t); // ID is on the last control point if(id == size_-1) { @@ -222,7 +221,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> //std::cout << "for val t="<<t<<" alpha="<<alpha<<" coef : h00="<<h00<<" h10="<<h10<<" h01="<<h01<<" h11="<<h11<<std::endl; Point p_ = (h00 * Pair0.first + h10 * dt * Pair0.second + h01 * Pair1.first + h11 * dt * Pair1.second); // if derivative, divide by dt^order_derivative - for (int i=0; i<order_derivative; i++) + for (std::size_t i=0; i<order_derivative; i++) { p_ /= dt; } @@ -290,7 +289,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> /// \param t : time where to look for interval. /// \return Index of interval for time t. /// - Index findInterval(const Numeric t) const + std::size_t findInterval(const Numeric t) const { // time before first control point time. if(t < time_control_points_[0]) @@ -303,11 +302,11 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> return size_-1; } - Index left_id = 0; - Index right_id = size_-1; + std::size_t left_id = 0; + std::size_t right_id = size_-1; while(left_id <= right_id) { - const Index middle_id = left_id + (right_id - left_id)/2; + const std::size_t middle_id = left_id + (right_id - left_id)/2; if(time_control_points_.at(middle_id) < t) { left_id = middle_id+1; @@ -332,7 +331,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> duration_splines_.clear(); Time actual_time; Time prev_time = *(time_control_points_.begin()); - Index i = 0; + std::size_t i = 0; for (i=0; i<size()-1; i++) { actual_time = time_control_points_.at(i+1); @@ -346,7 +345,7 @@ struct cubic_hermite_spline : public curve_abc<Time, Numeric, Dim, Safe, Point> /// bool checkDurationSplines() const { - Index i = 0; + std::size_t i = 0; bool is_positive = true; while (is_positive && i<duration_splines_.size()) { diff --git a/include/curves/piecewise_polynomial_curve.h b/include/curves/piecewise_polynomial_curve.h index bec4433a4b081ea8be6d7fdcf4cacfd16e6274ee..203bbd5b934f32e0fcfc4aa47dbfbd3c6eb6750f 100644 --- a/include/curves/piecewise_polynomial_curve.h +++ b/include/curves/piecewise_polynomial_curve.h @@ -17,10 +17,9 @@ namespace curves /// \class PiecewiseCurve. /// \brief Represent a piecewise polynomial curve. We can add some new polynomials to the curve, /// but the starting time of the polynomial to add should be equal to the ending time of the -/// piecewise_polynomial_curve.\n -/// Example : A piecewise polynomial curve composed of three polynomials pol_0, pol_1 and pol_2 -/// where pol_0 is defined between \f$[T0_{min},T0_{max}]\f$, pol_1 between \f$[T0_{max},T1_{max}]\f$ -/// and pol_2 between \f$[T1_{max},T2_{max}]\f$. +/// piecewise_polynomial_curve.<br>\ Example : A piecewise polynomial curve composed of three polynomials pol_0, +/// pol_1 and pol_2 where pol_0 is defined between \f$[T0_{min},T0_{max}]\f$, pol_1 between +/// \f$[T0_{max},T1_{max}]\f$ and pol_2 between \f$[T1_{max},T2_{max}]\f$. /// On the piecewise polynomial curve, pol_0 is located between \f$[T0_{min},T0_{max}[\f$, /// pol_1 between \f$[T0_{max},T1_{max}[\f$ and pol_2 between \f$[T1_{max},T2_{max}]\f$. /// @@ -35,7 +34,6 @@ struct piecewise_polynomial_curve : public curve_abc<Time, Numeric, Dim, Safe, P typedef T_Point t_point_t; typedef Time time_t; typedef Numeric num_t; - typedef int Index; //typedef polynomial <double, double, 3, true, point_t, t_point_t> polynomial_t; typedef polynomial <double, double, 3, true, point_t, t_point_t> polynomial_t; @@ -105,8 +103,9 @@ struct piecewise_polynomial_curve : public curve_abc<Time, Numeric, Dim, Safe, P /// bool is_continuous(const std::size_t order) { + double margin = 0.001; bool isContinuous = true; - Index i=0; + std::size_t i=0; point_t value_end, value_start; while (isContinuous && i<(size_-1)) { @@ -139,7 +138,7 @@ struct piecewise_polynomial_curve : public curve_abc<Time, Numeric, Dim, Safe, P /// \param t : time where to look for interval. /// \return Index of interval for time t. /// - Index find_interval(const Numeric t) const + std::size_t find_interval(const Numeric t) const { // time before first control point time. if(t < time_polynomial_curves_[0]) @@ -152,11 +151,11 @@ struct piecewise_polynomial_curve : public curve_abc<Time, Numeric, Dim, Safe, P return size_-1; } - Index left_id = 0; - Index right_id = size_-1; + std::size_t left_id = 0; + std::size_t right_id = size_-1; while(left_id <= right_id) { - const Index middle_id = left_id + (right_id - left_id)/2; + const std::size_t middle_id = left_id + (right_id - left_id)/2; if(time_polynomial_curves_.at(middle_id) < t) { left_id = middle_id+1; @@ -186,9 +185,8 @@ struct piecewise_polynomial_curve : public curve_abc<Time, Numeric, Dim, Safe, P /* Variables */ t_polynomial_t polynomial_curves_; // for curves 0/1/2 : [ curve0, curve1, curve2 ] t_vector_time_t time_polynomial_curves_; // for curves 0/1/2 : [ Tmin0, Tmax0,Tmax1,Tmax2 ] - Numeric size_; // Number of segments in piecewise curve = size of polynomial_curves_ + std::size_t size_; // Number of segments in piecewise curve = size of polynomial_curves_ Time T_min_, T_max_; - const double margin = 0.001; }; } // end namespace diff --git a/tests/Main.cpp b/tests/Main.cpp index 0cd863014f38d0006b7c3794e94acdb8cf4f3f90..62eece4287d11fb876f2f3daffe9c5a6661c9de2 100644 --- a/tests/Main.cpp +++ b/tests/Main.cpp @@ -484,6 +484,7 @@ void toPolynomialConversionTest(bool& error) double T_max = 3.0; bezier_curve_t bc(control_points.begin(), control_points.end(),T_min, T_max); polynomial_t pol = polynomial_from_curve<polynomial_t, bezier_curve_t>(bc); + compareCurves<polynomial_t, bezier_curve_t>(pol, bc, errMsg, error); } void cubicConversionTest(bool& error) @@ -956,7 +957,7 @@ void BezierEvalDeCasteljau(bool& error) void BezierSplitCurve(bool& error) { // test for degree 5 - int n = 5; + size_t n = 5; double t_min = 0.2; double t_max = 10; for(size_t i = 0 ; i < 1 ; ++i)