18 #include "../../include/ecl/geometry/cubic_spline.hpp" 25 namespace blueprints {
47 if (x_data.size() < 2 || y_data.size() < 2)
52 unsigned int n = x_data.size();
58 u[0] = (3.0/(x_data[1]-x_data[0])) * ((y_data[1]-y_data[0])/(x_data[1]-x_data[0])-ydot_0);
60 for (
unsigned int i = 1; i <= n-2; ++i){
61 double sig = (x_data[i]-x_data[i-1]) / (x_data[i+1]-x_data[i-1]);
62 double p = sig*yddot_data[i-1]+2.0;
63 yddot_data[i] = (sig-1.0)/p;
64 u[i] = (y_data[i+1]-y_data[i])/(x_data[i+1]-x_data[i]) -
65 (y_data[i]-y_data[i-1])/(x_data[i]-x_data[i-1]);
66 u[i] = (6.0*u[i]/(x_data[i+1]-x_data[i-1]) - sig*u[i-1])/p;
70 u[n-1] = (3.0/(x_data[n-1]-x_data[n-2])) * (ydot_f - (y_data[n-1]-y_data[n-2])/(x_data[n-1]-x_data[n-2]));
73 yddot_data[n-1] = ( u[n-1] - qn*u[n-2]) / ( qn*yddot_data[n-2] + 1.0 );
74 for (
int k = n-2; k >= 0; --k ) {
75 yddot_data[k] = yddot_data[k]*yddot_data[k+1] + u[k];
87 if (x_data.size() < 2 || y_data.size() < 2)
92 unsigned int n = x_data.size();
100 for (
unsigned int i = 1; i <= n-2; ++i){
101 double sig = (x_data[i]-x_data[i-1]) / (x_data[i+1]-x_data[i-1]);
102 double p = sig*yddot_data[i-1]+2.0;
103 yddot_data[i] = (sig-1.0)/p;
104 u[i] = (y_data[i+1]-y_data[i])/(x_data[i+1]-x_data[i]) -
105 (y_data[i]-y_data[i-1])/(x_data[i]-x_data[i-1]);
106 u[i] = (6.0*u[i]/(x_data[i+1]-x_data[i-1]) - sig*u[i-1])/p;
113 yddot_data[n-1] = ( u[n-1] - qn*u[n-2]) / ( qn*yddot_data[n-2] + 1.0 );
114 for (
int k = n-2; k >= 0; --k ) {
115 yddot_data[k] = yddot_data[k]*yddot_data[k+1] + u[k];
151 ydot_data[0] = ydot_0;
152 for (
unsigned int i = 1; i < (
x_data.
size()-1); ++i ) {
153 double ydot_before, ydot_after;
156 ydot_data[i] = (ydot_before + ydot_after)/2;
198 return DerivativeHeuristicCubicSpline(x_set, y_set, ydot_0, ydot_f);
Array< CubicPolynomial > cubic_polynomials
Embedded control libraries.
Blueprint for generating a cubic spline satisfying C2 constraints.
#define ecl_throw(exception)
#define ecl_assert_throw(expression, exception)
void apply(ecl::CubicSpline &spline) const
Apply the blueprint to configure an existing object.
ecl::CubicSpline instantiate()
Instantiate a copy of the object that is blueprinted.
DerivativeHeuristicCubicSpline()
Default constructor.
Storage container for a cubic spline interpolation.
Array< double > discretised_domain
ecl::Array< double > yddot_data
#define ecl_assert_throw_decl(exception)
ecl::Array< double > x_data
Blueprint for generating a cubic spline satisfying C2 constraints.
void apply(ecl::CubicSpline &spline) const
Apply the blueprint to configure an existing object.
C2CubicSpline(const ecl::Array< double > &x_set, const ecl::Array< double > &y_set) ecl_assert_throw_decl(ecl ecl::CubicSpline instantiate()
Constructor that properly configures/initialises the blueprint.
C2CubicSpline()
Default constructor.
ecl::Array< double > y_data