18 #include "../../include/ecl/geometry/smooth_linear_spline.hpp" 32 if ( x_data.size() != y_data.size() ) {
41 unsigned int n = x_data.size()-1;
48 discretised_domain.resize(2*n);
53 for (
unsigned int i = 0; i < n; ++i ) {
54 segments[i] = LinearFunction::Interpolation(x_data[i],y_data[i],x_data[i+1],y_data[i+1]);
56 discretised_domain[0] = x_data[0];
57 discretised_domain[2*n-1] = x_data[n];
62 for (
unsigned int i = 1; i < n; ++i ) {
63 if ( segments[i-1].coefficients()[1] == segments[i].coefficients()[1] ) {
65 corners[i-1].coefficients() << segments[i-1].coefficients()[0], segments[i-1].coefficients()[1], 0.0, 0.0, 0.0, 0.0;
66 discretised_domain[1+2*(i-1)] = x_data[i];
67 discretised_domain[1+2*(i-1)+1] = x_data[i];
69 for (
unsigned int j = 1; j <= 5; ++j ) {
72 x_l = x_data[i] - j*(x_data[i]-x_data[i-1])/5;
74 x_l = x_data[i] - j*(x_data[i]-x_data[i-1])/10;
77 x_r = x_data[i] + j*(x_data[i+1]-x_data[i])/5;
79 x_r = x_data[i] + j*(x_data[i+1]-x_data[i])/10;
81 double y_l = segments[i-1](x_l);
82 double y_r = segments[i](x_r);
83 double ydot_l = segments[i-1].derivative(x_l);
84 double ydot_r = segments[i].derivative(x_r);
85 corners[i-1] = QuinticPolynomial::Interpolation(x_l,y_l,ydot_l,0.0,
89 discretised_domain[1+2*(i-1)] = x_l;
90 discretised_domain[1+2*(i-1)+1] = x_r;
115 while ( x > discretised_domain[index+1] ) {
118 if ( index % 2 == 0 ) {
119 return segments[index/2](x);
121 return corners[(index-1)/2](x);
128 while ( x > discretised_domain[index+1] ) {
131 if ( index % 2 == 0 ) {
132 return segments[index/2].derivative(x);
134 return corners[(index-1)/2].derivative(x);
141 while ( x > discretised_domain[index+1] ) {
144 if ( index % 2 == 0 ) {
145 return segments[index/2].dderivative(x);
147 return corners[(index-1)/2].dderivative(x);
Embedded control libraries.
double dderivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline second derivative.
Mathematical minimum on a compact interval for cubic polynomials.
#define ecl_assert_throw(expression, exception)
double operator()(const double &x) const ecl_assert_throw_decl(StandardException)
Spline function.
Mathematical maximum on a compact interval for cubic polynomials.
#define ecl_assert_throw_decl(exception)
SmoothLinearSpline()
Default constructor.
double derivative(const double &x) const ecl_assert_throw_decl(StandardException)
Spline derivative.