tension_function.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_GEOMETRY_TENSION_FUNCTION_HPP_
00013 #define ECL_GEOMETRY_TENSION_FUNCTION_HPP_
00014 
00015 /*****************************************************************************
00016 ** Includes
00017 *****************************************************************************/
00018 
00019 #include "function_math.hpp"
00020 #include <ecl/config/macros.hpp>
00021 #include <ecl/concepts/macros.hpp>
00022 #include <ecl/concepts/streams.hpp>
00023 #include <ecl/containers/array.hpp>
00024 #include <ecl/errors/compile_time_assert.hpp>
00025 #include <ecl/utilities/blueprints.hpp>
00026 #include <ecl/formatters/floats.hpp>
00027 
00028 /*****************************************************************************
00029 ** Namespaces
00030 *****************************************************************************/
00031 
00032 namespace ecl {
00033 
00034 /*****************************************************************************
00035 ** Forward Declarations
00036 *****************************************************************************/
00037 
00038 class TensionFunction;
00039 
00040 namespace blueprints {
00041 
00042 class TensionSecondDerivativeInterpolation;
00043 
00044 } // namespace blueprints
00045 
00046 /*****************************************************************************
00047 ** BluePrintFactory
00048 *****************************************************************************/
00057 template<>
00058 class ECL_PUBLIC BluePrintFactory< TensionFunction > {
00059     public:
00077         static blueprints::TensionSecondDerivativeInterpolation Interpolation(const double x_i, const double y_i, const double yddot_i,
00078                 const double x_f, const double y_f, const double yddot_f);
00079 
00080         virtual ~BluePrintFactory() {};
00081 };
00082 
00083 /*****************************************************************************
00084 ** Interface [TensionFunction]
00085 *****************************************************************************/
00110 class ECL_PUBLIC TensionFunction : public BluePrintFactory< TensionFunction > {
00111     public:
00112         /*********************
00113         ** Constructors
00114         **********************/
00121         TensionFunction() {}
00122         virtual ~TensionFunction() {}
00145         template<typename Derived>
00146         TensionFunction(const BluePrint< Derived > &blueprint) {
00147             blueprint.implementApply(*this);
00148         }
00149 
00150         /*********************
00151         ** Derivatives
00152         **********************/
00163         double derivative(const double &tau, const double &x) const;
00164 
00175         double dderivative(const double &tau, const double &x) const;
00176 
00177         /*********************
00178         ** Accessors
00179         **********************/
00190         double operator ()(const double &tau, const double &x) const;
00191 
00192         /*********************
00193         ** Friends
00194         **********************/
00195         friend class blueprints::TensionSecondDerivativeInterpolation;
00196 
00197 
00198         template <typename OutputStream>
00199         friend OutputStream& operator << (OutputStream &ostream, const TensionFunction &function);
00200 
00201     private:
00202         double z_0, z_f; // yddot_0, yddot_f
00203         double x_0, x_f;
00204         double y_0, y_f;
00205 };
00206 
00207 
00208 /*****************************************************************************
00209 ** Streaming Operator [TensionFunction]
00210 *****************************************************************************/
00222 template <typename OutputStream>
00223 OutputStream& operator << (OutputStream &ostream, const TensionFunction &function)
00224 {
00225         ecl_compile_time_concept_check(StreamConcept<OutputStream>);
00226 
00227     Format<double> format;
00228     format.precision(2);
00229     double h = function.x_f - function.x_0;
00230     if ( ( function.z_0 == 0.0 ) && ( function.z_f == 0.0 ) ) {
00231         ostream << "0.0";
00232     } else {
00233         ostream << "{";
00234         if ( function.z_0 != 0.0 ) {
00235             ostream << format(function.z_0) << "*sinh[tau(";
00236             ostream << format(function.x_f) << "-x)] + ";
00237         }
00238         if ( function.z_f != 0.0 ) {
00239             ostream << format(function.z_f) << "*sinh[tau(x-";
00240             ostream << format(function.x_0) << ")]}/[tau^2 sinh(";
00241             ostream << format(function.x_f - function.x_0) << "*tau)]";
00242         }
00243     }
00244     ostream << "\n";
00245     ostream << "        + (";
00246     ostream << format(function.y_0/h) << "-";
00247     ostream << format(function.z_0/h) << "/tau^2)(";
00248     ostream << format(function.x_f) << "-x)\n";
00249     ostream << "                    + (";
00250     ostream << format(function.y_f/h) << "-";
00251     ostream << format(function.z_f/h) << "/tau^2)(x-";
00252     ostream << format(function.x_0) << ")\n";
00253     ostream.flush();
00254 
00255     return ostream;
00256 }
00257 
00258 /*****************************************************************************
00259 ** BluePrints
00260 *****************************************************************************/
00261 
00262 namespace blueprints {
00263 
00264 /*****************************************************************************
00265 ** Interface [TensionSecondDerivativeInterpolation]
00266 *****************************************************************************/
00267 
00284 class ECL_PUBLIC TensionSecondDerivativeInterpolation : public ecl::BluePrint<TensionSecondDerivativeInterpolation> {
00285     public:
00289         typedef ecl::TensionFunction base_type;
00302         TensionSecondDerivativeInterpolation(const double x_i, const double y_i, const double yddot_i,
00303                 const double x_f, const double y_f, const double yddot_f) :
00304                     x_initial(x_i),
00305                     y_initial(y_i),
00306                     yddot_initial(yddot_i),
00307                     x_final(x_f),
00308                     y_final(y_f),
00309                     yddot_final(yddot_f)
00310         {}
00311         virtual ~TensionSecondDerivativeInterpolation() {}
00312 
00320         ecl::TensionFunction instantiate();
00321 
00329         void apply(base_type& function) const;
00330 
00331     private:
00332         double x_initial, y_initial, yddot_initial;
00333         double x_final, y_final, yddot_final;
00334 };
00335 
00336 
00337 }; // namespace blueprints
00338 }; // namespace ecl
00339 
00340 #endif /*ECL_GEOMETRY_TENSION_FUNCTION_HPP_*/


ecl_geometry
Author(s): Daniel Stonier
autogenerated on Mon Jul 3 2017 02:21:51