Commit 899dd9db by Pierre Fernbach

[piecewise] refactor/simplify constructor from discret point

parent 4cc0b596
 ... ... @@ -216,51 +216,23 @@ namespace curves } template static piecewise_curve convert_discrete_points_to_polynomial(T_Point points, Time T_min, Time T_max) static piecewise_curve convert_discrete_points_to_polynomial(T_Point points, t_time_t time_points) { if(Safe &! (points.size()>1)) { //std::cout<<"[Min,Max]=["< convert_discrete_points_to_polynomial, Error, less than 2 discrete points"); throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, less than 2 discrete points"); } typedef piecewise_curve piecewise_curve_out_t; Time discretization_step = (T_max-T_min)/Time(points.size()-1); Time time_actual = T_min; // Initialization at first points point_t actual_point = points[0]; point_t next_point = points[1]; point_t coeff_order_zero(actual_point); point_t coeff_order_one((next_point-actual_point)/discretization_step); t_point_t coeffs; coeffs.push_back(coeff_order_zero); coeffs.push_back(coeff_order_one); Polynomial pol(coeffs,time_actual,time_actual+discretization_step); piecewise_curve_out_t ppc(pol); time_actual += discretization_step; // Other points for (std::size_t i=1; i piecewise_res; for(size_t i = 1 ; i < points.size() ; ++i){ piecewise_res.add_curve(Polynomial(points[i-1],points[i],time_points[i-1],time_points[i])); } // Last points coeffs.clear(); actual_point = points[points.size()-2]; next_point = points[points.size()-1]; coeff_order_zero = actual_point; coeff_order_one = (next_point-actual_point)/discretization_step; coeffs.push_back(coeff_order_zero); coeffs.push_back(coeff_order_one); ppc.add_curve(Polynomial(coeffs,time_actual,T_max)); return ppc; return piecewise_res; } private: ... ... @@ -357,4 +329,4 @@ namespace curves } // end namespace #endif // _CLASS_PIECEWISE_CURVE \ No newline at end of file #endif // _CLASS_PIECEWISE_CURVE
 ... ... @@ -1335,37 +1335,28 @@ void curveAbcDimDynamicTest(bool& error) void piecewiseCurveConversionFromDiscretePointsTest(bool& error) { try { std::string errMsg("piecewiseCurveConversionFromDiscretePointsTest, Error, value on curve is wrong : "); point_t p0(0.,0.,0.); point_t p1(1.,2.,3.); point_t p2(4.,4.,4.); point_t p3(10.,10.,10.); point_t p_test_0_5 = (p0+p1)/2.0; t_point_t points; points.push_back(p0); points.push_back(p1); points.push_back(p2); points.push_back(p3); double T_min = 1.0; double T_max = 3.0; double timestep = (T_max-T_min)/double(points.size()-1); piecewise_polynomial_curve_t ppc = piecewise_polynomial_curve_t:: convert_discrete_points_to_polynomial(points,T_min,T_max); if (!ppc.is_continuous(0)) { std::cout<<"piecewiseCurveConversionFromDiscretePointsTest, Error, piecewise curve is not C0"< time_points; for(size_t i=0;i(points,time_points); if (!ppc.is_continuous(0)) { std::cout<<"piecewiseCurveConversionFromDiscretePointsTest, Error, piecewise curve is not C0"<
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!