Resolved that annoying gravity bug and added trajectories, a grid, keyboard navigation and logarithimic scale
This commit is contained in:
+15
-10
@@ -7,22 +7,27 @@
|
||||
#pragma once
|
||||
#include <glm/glm.hpp>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CelestialBody {
|
||||
public:
|
||||
CelestialBody(float mass, const glm::vec3& position, const glm::vec3& velocity);
|
||||
CelestialBody(double mass, const glm::dvec3& position, const glm::dvec3& velocity);
|
||||
|
||||
void update(float dt);
|
||||
void applyForce(const glm::vec3& force);
|
||||
void update(double dt);
|
||||
void applyForce(const glm::dvec3& force);
|
||||
|
||||
float getMass() const { return mass; }
|
||||
glm::vec3 getPosition() const { return position; }
|
||||
glm::vec3 getVelocity() const { return velocity; }
|
||||
[[nodiscard]] double getMass() const { return mass; }
|
||||
[[nodiscard]] glm::dvec3 getPosition() const { return position; }
|
||||
[[nodiscard]] glm::dvec3 getVelocity() const { return velocity; }
|
||||
void addToTrajectory(const glm::dvec3& position);
|
||||
const std::vector<glm::dvec3>& getTrajectory() const { return trajectory; }
|
||||
|
||||
private:
|
||||
float mass;
|
||||
glm::vec3 position;
|
||||
glm::vec3 velocity;
|
||||
glm::vec3 acceleration;
|
||||
double mass;
|
||||
glm::dvec3 position;
|
||||
glm::dvec3 velocity;
|
||||
glm::dvec3 acceleration;
|
||||
std::vector<glm::dvec3> trajectory;
|
||||
static const size_t MAX_TRAJECTORY_POINTS = 1000;
|
||||
};
|
||||
#endif //GRAVITY_CELESTIALBODY_H
|
||||
|
||||
Reference in New Issue
Block a user