]> git.localhorst.tv Git - blobs.git/blobdiff - src/world/Body.hpp
concerning orbits
[blobs.git] / src / world / Body.hpp
index e3fd8ded17d2684befa5436fa76891b2c6ab3099..2f87d22723cd2239575355bf5153c006ef8d13af 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef BLOBS_WORLD_BODY_HPP_
 #define BLOBS_WORLD_BODY_HPP_
 
+#include "../graphics/glm.hpp"
+
 #include <vector>
 
 
@@ -13,6 +15,8 @@ namespace graphics {
 }
 namespace world {
 
+class Simulation;
+
 class Body {
 
 public:
@@ -26,12 +30,46 @@ public:
        Body &operator =(Body &&) = delete;
 
 public:
+       bool HasSimulation() const noexcept { return sim; }
+       const Simulation &GetSimulation() const noexcept { return *sim; }
+       void SetSimulation(Simulation &) noexcept;
+
        bool HasParent() const { return parent; }
        Body &Parent() { return *parent; }
        const Body &Parent() const { return *parent; }
        void SetParent(Body &);
        void UnsetParent();
 
+       double Mass() const noexcept;
+       void Mass(double) noexcept;
+
+       double Radius() const noexcept;
+       void Radius(double) noexcept;
+
+       double SemiMajorAxis() const noexcept;
+       void SemiMajorAxis(double) noexcept;
+
+       double Eccentricity() const noexcept;
+       void Eccentricity(double) noexcept;
+
+       double Inclination() const noexcept;
+       void Inclination(double) noexcept;
+
+       double LongitudeAscending() const noexcept;
+       void LongitudeAscending(double) noexcept;
+
+       double ArgumentPeriapsis() const noexcept;
+       void ArgumentPeriapsis(double) noexcept;
+
+       double MeanAnomaly() const noexcept;
+       void MeanAnomaly(double) noexcept;
+
+       double GravitationalParameter() const noexcept;
+       double OrbitalPeriod() const noexcept;
+
+       glm::mat4 ToParent() const noexcept;
+       glm::mat4 FromParent() const noexcept;
+
        virtual void Draw(app::Assets &, graphics::Viewport &) { }
 
 private:
@@ -39,11 +77,20 @@ private:
        void RemoveChild(Body &);
 
 private:
+       Simulation *sim;
        Body *parent;
        std::vector<Body *> children;
        double mass;
        double radius;
 
+       // Orbit
+       double sma; // semi-major axis
+       double ecc; // eccentricity
+       double inc; // inclination
+       double asc; // longitude of ascending node
+       double arg; // argument of periapsis
+       double mna; // mean anomaly (at t=0)
+
 };
 
 }