Commit 899dd9db by Pierre Fernbach

[piecewise] refactor/simplify constructor from discret point

parent 4cc0b596
 ... @@ -216,51 +216,23 @@ namespace curves ... @@ -216,51 +216,23 @@ namespace curves } } template template static piecewise_curve static piecewise_curve convert_discrete_points_to_polynomial(T_Point points, Time T_min, Time T_max) convert_discrete_points_to_polynomial(T_Point points, t_time_t time_points) { { if(Safe &! (points.size()>1)) 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; if(points.size() != time_points.size()){ Time discretization_step = (T_max-T_min)/Time(points.size()-1); throw std::invalid_argument("piecewise_curve::convert_discrete_points_to_polynomial: Error, points and time_points must have the same size."); Time time_actual = T_min; } // Initialization at first points piecewise_curve piecewise_res; point_t actual_point = points[0]; point_t next_point = points[1]; for(size_t i = 1 ; i < points.size() ; ++i){ point_t coeff_order_zero(actual_point); piecewise_res.add_curve(Polynomial(points[i-1],points[i],time_points[i-1],time_points[i])); 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
 ... @@ -1335,37 +1335,28 @@ void curveAbcDimDynamicTest(bool& error) ... @@ -1335,37 +1335,28 @@ void curveAbcDimDynamicTest(bool& error) void piecewiseCurveConversionFromDiscretePointsTest(bool& error) void piecewiseCurveConversionFromDiscretePointsTest(bool& error) { { try std::string errMsg("piecewiseCurveConversionFromDiscretePointsTest, Error, value on curve is wrong : "); { point_t p0(0.,0.,0.); std::string errMsg("piecewiseCurveConversionFromDiscretePointsTest, Error, value on curve is wrong : "); point_t p1(1.,2.,3.); point_t p0(0.,0.,0.); point_t p2(4.,4.,4.); point_t p1(1.,2.,3.); point_t p3(10.,10.,10.); point_t p2(4.,4.,4.); point_t p_test_0_5 = (p0+p1)/2.0; point_t p3(10.,10.,10.); t_point_t points; point_t p_test_0_5 = (p0+p1)/2.0; points.push_back(p0); t_point_t points; points.push_back(p1); points.push_back(p0); points.push_back(p2); points.push_back(p1); points.push_back(p3); points.push_back(p2); double T_min = 1.0; points.push_back(p3); double T_max = 3.0; double T_min = 1.0; double timestep = (T_max-T_min)/double(points.size()-1); double T_max = 3.0; std::vector time_points; double timestep = (T_max-T_min)/double(points.size()-1); for(size_t i=0;i(points,T_min,T_max); piecewise_polynomial_curve_t ppc = piecewise_polynomial_curve_t:: if (!ppc.is_continuous(0)) convert_discrete_points_to_polynomial(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!