lib/tension_function.cpp
Go to the documentation of this file.
1 
9 /*****************************************************************************
10 ** Includes
11 *****************************************************************************/
12 
13 #include <cmath>
14 #include "../../include/ecl/geometry/tension_function.hpp"
15 
16 /*****************************************************************************
17 ** Namespaces
18 *****************************************************************************/
19 
20 namespace ecl {
21 
22 /*****************************************************************************
23 ** Implementation [TensionFunction]
24 *****************************************************************************/
25 
26 double TensionFunction::derivative(const double &tau, const double &x) const {
27  double value;
28  double h = x_f-x_0;
29  value = (-1.0*tau*z_0*cosh(tau*(x_f-x)) + tau*z_f*cosh(tau*(x-x_0)))/(tau*tau*sinh(tau*h));
30  value += -1.0*(y_0-z_0/(tau*tau))/h;
31  value += (y_f-z_f/(tau*tau))/h;
32 
33  return value;
34 }
35 
36 
37 double TensionFunction::dderivative(const double &tau, const double &x) const {
38  double value;
39  double h = x_f-x_0;
40  value = (tau*tau*z_0*sinh(tau*(x_f-x)) + tau*tau*z_f*sinh(tau*(x-x_0)))/(tau*tau*sinh(tau*h));
41 
42  return value;
43 }
44 
45 double TensionFunction::operator ()(const double &tau, const double &x) const {
46  double value;
47  double h = x_f-x_0;
48  value = (z_0*sinh(tau*(x_f-x)) + z_f*sinh(tau*(x-x_0)))/(tau*tau*sinh(tau*h));
49  value += (y_0-z_0/(tau*tau))*(x_f-x)/h;
50  value += (y_f-z_f/(tau*tau))*(x-x_0)/h;
51  return value;
52 }
53 
54 namespace blueprints {
55 
57 
58 /*****************************************************************************
59 ** Implementation [TensionSecondDerivativeInterpolation]
60 *****************************************************************************/
61 
63  TensionFunction function;
64  apply(function);
65  return function;
66 }
67 
68 void TensionSecondDerivativeInterpolation::apply(base_type &function) const {
69 
70  // Dont have to do much here, just copy across the parameters
71  function.z_0 = yddot_initial;
72  function.z_f = yddot_final;
73  function.x_0 = x_initial;
74  function.x_f = x_final;
75  function.y_0 = y_initial;
76  function.y_f = y_final;
77 }
78 
79 }; // namespace blueprints
80 
82 
83 /*****************************************************************************
84 ** BluePrintFactory[TensionFunction]
85 *****************************************************************************/
86 
87 TensionSecondDerivativeInterpolation BluePrintFactory< TensionFunction >::Interpolation(const double x_i, const double y_i, const double yddot_i, const double x_f, const double y_f, const double yddot_f) {
88  return TensionSecondDerivativeInterpolation(x_i, y_i, yddot_i, x_f, y_f, yddot_f);
89 }
90 
91 } // namespace ecl
ecl::blueprints::TensionSecondDerivativeInterpolation::instantiate
ecl::TensionFunction instantiate()
Instantiate a copy of the object that is blueprinted.
Definition: lib/tension_function.cpp:66
ecl::blueprints::TensionSecondDerivativeInterpolation::x_final
double x_final
Definition: tension_function.hpp:345
ecl::TensionFunction::z_f
double z_f
Definition: tension_function.hpp:210
ecl::blueprints::TensionSecondDerivativeInterpolation::y_initial
double y_initial
Definition: tension_function.hpp:344
ecl::blueprints::TensionSecondDerivativeInterpolation::y_final
double y_final
Definition: tension_function.hpp:345
ecl::TensionFunction::y_0
double y_0
Definition: tension_function.hpp:212
ecl::TensionFunction::operator()
double operator()(const double &tau, const double &x) const
Calculates the value for a certain tension at the specified point.
Definition: lib/tension_function.cpp:49
ecl::TensionFunction::z_0
double z_0
Definition: tension_function.hpp:210
ecl::TensionFunction::y_f
double y_f
Definition: tension_function.hpp:212
ecl::blueprints::TensionSecondDerivativeInterpolation::apply
void apply(base_type &function) const
Apply the blueprint to configure an existing object.
Definition: lib/tension_function.cpp:72
ecl::blueprints::TensionSecondDerivativeInterpolation::yddot_final
double yddot_final
Definition: tension_function.hpp:345
ecl::TensionFunction
Representation of a tension function.
Definition: tension_function.hpp:116
ecl::blueprints::TensionSecondDerivativeInterpolation::yddot_initial
double yddot_initial
Definition: tension_function.hpp:344
ecl::TensionFunction::derivative
double derivative(const double &tau, const double &x) const
Generates the derivative for a certain tension at the specified point.
Definition: lib/tension_function.cpp:30
ecl::TensionFunction::x_0
double x_0
Definition: tension_function.hpp:211
ecl::TensionFunction::dderivative
double dderivative(const double &tau, const double &x) const
Generates the 2nd derivative for a certain tension at the specified point.
Definition: lib/tension_function.cpp:41
ecl::BluePrintFactory
ecl::TensionFunction::x_f
double x_f
Definition: tension_function.hpp:211
ecl
Embedded control libraries.
ecl::blueprints::TensionSecondDerivativeInterpolation::x_initial
double x_initial
Definition: tension_function.hpp:344
ecl::blueprints::TensionSecondDerivativeInterpolation
Blueprint for interpolating a tension function between end point conditions.
Definition: tension_function.hpp:292


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:39