17 #include "../../include/ecl/geometry/tension_spline.hpp"
24 namespace blueprints {
51 unsigned int n = x_data.size()-1;
52 yddot_data.resize(n+1);
63 h[0] = x_set[1] - x_set[0];
64 for (
unsigned int i = 0; i < n; ++i ) {
65 h[i] = x_set[i+1]-x_set[i];
66 a[i] = 1/h[i] - tension/sinh(tension*h[i]);
67 beta[i] = tension*(cosh(tension*h[i])/sinh(tension*h[i])) - 1/h[i];
68 gamma[i] = tension*tension*(y_data[i+1]-y_data[i])/h[i];
82 u[1] = beta[1] + beta[0];
83 v[1] = gamma[1]-gamma[0];
84 for (
unsigned int i = 2; i < n; ++i ) {
85 u[i] = beta[i] + beta[i-1] - a[i-1]*a[i-1]/u[i-1];
86 v[i] = gamma[i]-gamma[i-1] - a[i-1]*v[i-1]/u[i-1];
92 for (
unsigned int i = n-1; i > 0; --i ) {
93 yddot_data[i] = (v[i] - a[i]*yddot_data[i+1])/u[i];
98 TensionSpline C2TensionSpline::instantiate() {
104 void C2TensionSpline::apply(TensionSpline& spline)
const {
106 spline.discretised_domain = x_data;
107 spline.tension = tension;
108 spline.functions.resize(x_data.size()-1);
109 for (
unsigned int i = 0; i < spline.functions.size(); ++i ) {
110 spline.functions[i] = TensionFunction::Interpolation(
111 x_data[i], y_data[i], yddot_data[i],
112 x_data[i+1], y_data[i+1], yddot_data[i+1] );
122 using blueprints::C2TensionSpline;
125 C2TensionSpline BluePrintFactory< TensionSpline >::Natural(
const Array<double>& x_set,
126 const Array<double>& y_set,
const double &tau) {
127 return C2TensionSpline(x_set, y_set, tau);