Advertisement
Guest User

Untitled

a guest
May 28th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.83 KB | None | 0 0
  1. /*
  2.  * util.h in Dilatation du Temps
  3.  */
  4.  
  5. #ifndef UTIL_H_
  6. #define UTIL_H_
  7.  
  8. #include <type_traits>
  9. #include <vector>
  10. #include <iterator>
  11. #include <cmath>
  12.  
  13. namespace Mathematics {
  14.  
  15.     /**
  16.      * @need        #include <cmath>
  17.      * @parameter   ve (double) Speed ejection of gaz in meter/second
  18.      * @parameter   mi (double) Total mass of spacecraft at the start of propulsion in T
  19.      * @parameter   mf (double) Total mass of spacecraft during the propulsion in T
  20.      * @return      double(ve * std::log(mi/mf)) in meter/second
  21.      *              Growing up of speed in function of difference of mass between start and end of propulsion
  22.      */
  23.     double tsiolkovski_equation(double ve, double mi, double mf) {
  24.  
  25.         return ve * std::log(mi/mf); /* = *ve * (Integral(1, mi) 1/t * dt) - (Integral(1, mf) 1/t * dt)*/
  26.     }
  27.  
  28.     /**
  29.      * @need        #include <cmath>
  30.      * @parameter   ve (double) Speed ejection of gaz in meter/second
  31.      * @parameter   mi (double) Total mass of spacecraft at the start of propulsion in T
  32.      * @parameter   mf (double) Total mass of spacecraft during the propulsion in T
  33.      * @parameter   T (double) Time of propulsion in second
  34.      * @return      double(-ve * std::log(mi/mf) + 9.81 * T) in meter/second
  35.      *              Growing up of speed in function of difference of mass between start and end of propulsion including gravity factor
  36.      */
  37.     double tsiolkovski_equation_wGravity(double ve, double mi, double mf, double T) {
  38.  
  39.         return -ve * std::log(mi/mf) + 9.81 * T; /* = *ve * (Integral(1, mi) 1/t * dt) - (Integral(1, mf) 1/t * dt) - 9.81 * T*/
  40.     }
  41. } /* End of namespace Mathematics */
  42.  
  43. namespace OperationUtil {
  44.  
  45.     /**
  46.      * @need        #include <type_traits>
  47.      * @parameter   element1 (class template) First argument who compare to element2
  48.      * @parameter   element2 (class template) Second argument who compare to element1
  49.      * @return      true if two parameters are of the same type and equals.
  50.      * @warning     If, we check with two members class, this class must implements operator=
  51.      */
  52.     template <class Type1, class Type2>
  53.     bool comparator(Type1 element1, Type2 element2) {
  54.  
  55.         if (!(std::is_same<Type1, Type2>::value) ) {
  56.  
  57.             return false;
  58.  
  59.         } else {
  60.  
  61.             return element1 == element2; //Dependency class must use overloading of operator=
  62.         }
  63.     }
  64.  
  65.     /**
  66.      * @need        #include <vector> & #include <iterator>
  67.      * @parameter   v (const std::vector<template typename T>&) Displayable content.
  68.      * @return      Display content of v
  69.      * @warning     Out of range exception using parallel programming
  70.      */
  71.     template<typename T>
  72.     std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  73.  
  74.         std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
  75.         return out;
  76.     }
  77. } /* End of namespace OperationUtil */
  78.  
  79. namespace Constants {
  80.  
  81.     const std::size_t   SPEED_LIGHT_ms      = 299792458;                        /* Speed of light in meter/second */
  82. } /* End of namespace Constants */
  83.  
  84.  
  85. #endif /* UTIL_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement