1 /***************************************************************************** 2 * Copyright (C) 2004-2018 The pykep development team, * 3 * Advanced Concepts Team (ACT), European Space Agency (ESA) * 4 * * 5 * https://gitter.im/esa/pykep * 6 * https://github.com/esa/pykep * 7 * * 8 * act@esa.int * 9 * * 10 * This program is free software; you can redistribute it and/or modify * 11 * it under the terms of the GNU General Public License as published by * 12 * the Free Software Foundation; either version 2 of the License, or * 13 * (at your option) any later version. * 14 * * 15 * This program is distributed in the hope that it will be useful, * 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 18 * GNU General Public License for more details. * 19 * * 20 * You should have received a copy of the GNU General Public License * 21 * along with this program; if not, write to the * 22 * Free Software Foundation, Inc., * 23 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 24 *****************************************************************************/ 25 26 #ifndef KEP_TOOLBOX_PLANET_BASE_H 27 #define KEP_TOOLBOX_PLANET_BASE_H 28 29 #include <boost/shared_ptr.hpp> 30 #include <string> 31 32 #include <keplerian_toolbox/astro_constants.hpp> 33 #include <keplerian_toolbox/detail/visibility.hpp> 34 #include <keplerian_toolbox/epoch.hpp> 35 #include <keplerian_toolbox/exceptions.hpp> 36 #include <keplerian_toolbox/serialization.hpp> 37 38 namespace kep_toolbox 39 { 40 namespace planet 41 { 42 43 // Forward declaration. 44 class KEP_TOOLBOX_DLL_PUBLIC base; 45 typedef boost::shared_ptr<base> planet_ptr; 46 47 /// Base class for planet 48 /** 49 * A base planet in pykep is defined by its name, its radius, its safe radius (i.e. how close to it its considered to be 50 * safe) 51 * its gravity parameter and the gravitational parameter of the attracting body. All classes deriving from planet::base 52 * will have to implement the planet ephemerides planet::base::eph_impl which is the core method of this class. 53 * 54 * @author Dario Izzo (dario.izzo _AT_ googlemail.com) 55 */ 56 57 class KEP_TOOLBOX_DLL_PUBLIC base 58 { 59 public: 60 base(double mu_central_body = 0.1, double mu_self = 0.1, double radius = 0.1, double safe_radius = 0.1, 61 const std::string &name = "Unknown"); 62 virtual planet_ptr clone() const = 0; ~base()63 virtual ~base(){}; 64 65 /// Ephemerides methods 66 void eph(const epoch &when, array3D &r, array3D &v) const; 67 void eph(const double mjd2000, array3D &r, array3D &v) const; 68 69 /// Simple basic keplerian mechanics computations 70 array6D compute_elements(const epoch &when = kep_toolbox::epoch(0)) const; 71 double compute_period(const epoch &when = kep_toolbox::epoch(0)) const; 72 73 /// Methods to stream the base and derived class in a human readable format 74 std::string human_readable() const; human_readable_extra() const75 virtual std::string human_readable_extra() const 76 { 77 return std::string(); 78 } 79 80 /** @name Getters */ 81 //@{ 82 double get_mu_central_body() const; 83 double get_mu_self() const; 84 double get_radius() const; 85 double get_safe_radius() const; 86 std::string get_name() const; 87 //@} 88 89 /** @name Setters */ 90 //@{ 91 void set_safe_radius(double sr); 92 void set_mu_central_body(double mu); 93 void set_mu_self(double mu); 94 void set_radius(double radius); 95 void set_name(const std::string &radius); 96 //@} 97 98 protected: 99 virtual void eph_impl(double mjd2000, array3D &r, array3D &v) const = 0; 100 101 private: 102 friend class boost::serialization::access; 103 template <class Archive> serialize(Archive & ar,const unsigned int)104 void serialize(Archive &ar, const unsigned int) 105 { 106 ar &m_mu_central_body; 107 ar &m_mu_self; 108 ar &m_radius; 109 ar &m_safe_radius; 110 ar &m_name; 111 } 112 113 double m_mu_central_body; 114 double m_mu_self; 115 double m_radius; 116 double m_safe_radius; 117 std::string m_name; 118 }; 119 120 KEP_TOOLBOX_DLL_PUBLIC std::ostream &operator<<(std::ostream &s, const base &body); 121 } 122 } /// End of namespace kep_toolbox planet 123 124 BOOST_SERIALIZATION_ASSUME_ABSTRACT(kep_toolbox::planet::base) 125 126 #endif // KEP_TOOLBOX_PLANET_BASE_H 127