Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * util.h in Dilatation du Temps
- */
- #ifndef UTIL_H_
- #define UTIL_H_
- #include <type_traits>
- #include <vector>
- #include <iterator>
- #include <cmath>
- namespace Mathematics {
- /**
- * @need #include <cmath>
- * @parameter ve (double) Speed ejection of gaz in meter/second
- * @parameter mi (double) Total mass of spacecraft at the start of propulsion in T
- * @parameter mf (double) Total mass of spacecraft during the propulsion in T
- * @return double(ve * std::log(mi/mf)) in meter/second
- * Growing up of speed in function of difference of mass between start and end of propulsion
- */
- double tsiolkovski_equation(double ve, double mi, double mf) {
- return ve * std::log(mi/mf); /* = *ve * (Integral(1, mi) 1/t * dt) - (Integral(1, mf) 1/t * dt)*/
- }
- /**
- * @need #include <cmath>
- * @parameter ve (double) Speed ejection of gaz in meter/second
- * @parameter mi (double) Total mass of spacecraft at the start of propulsion in T
- * @parameter mf (double) Total mass of spacecraft during the propulsion in T
- * @parameter T (double) Time of propulsion in second
- * @return double(-ve * std::log(mi/mf) + 9.81 * T) in meter/second
- * Growing up of speed in function of difference of mass between start and end of propulsion including gravity factor
- */
- double tsiolkovski_equation_wGravity(double ve, double mi, double mf, double T) {
- 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*/
- }
- } /* End of namespace Mathematics */
- namespace OperationUtil {
- /**
- * @need #include <type_traits>
- * @parameter element1 (class template) First argument who compare to element2
- * @parameter element2 (class template) Second argument who compare to element1
- * @return true if two parameters are of the same type and equals.
- * @warning If, we check with two members class, this class must implements operator=
- */
- template <class Type1, class Type2>
- bool comparator(Type1 element1, Type2 element2) {
- if (!(std::is_same<Type1, Type2>::value) ) {
- return false;
- } else {
- return element1 == element2; //Dependency class must use overloading of operator=
- }
- }
- /**
- * @need #include <vector> & #include <iterator>
- * @parameter v (const std::vector<template typename T>&) Displayable content.
- * @return Display content of v
- * @warning Out of range exception using parallel programming
- */
- template<typename T>
- std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
- std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, " "));
- return out;
- }
- } /* End of namespace OperationUtil */
- namespace Constants {
- const std::size_t SPEED_LIGHT_ms = 299792458; /* Speed of light in meter/second */
- } /* End of namespace Constants */
- #endif /* UTIL_H_ */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement