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 
62 ecl::TensionFunction TensionSecondDerivativeInterpolation::instantiate() {
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
Embedded control libraries.
double dderivative(const double &tau, const double &x) const
Generates the 2nd derivative for a certain tension at the specified point.
double derivative(const double &tau, const double &x) const
Generates the derivative for a certain tension at the specified point.
Representation of a tension function.
double operator()(const double &tau, const double &x) const
Calculates the value for a certain tension at the specified point.
Blueprint for interpolating a tension function between end point conditions.


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jun 10 2019 13:08:37