Little things
This commit is contained in:
@@ -6,24 +6,58 @@
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
glm::dvec3 calculateOrbitalVelocity(double centralMass, double distance) {
|
||||
const double G = 6.67430e-11;
|
||||
double speed = std::sqrt(G * centralMass / distance);
|
||||
return glm::dvec3(0, speed, 0); // Assuming orbit in the XZ plane
|
||||
}
|
||||
|
||||
int main() {
|
||||
Simulator simulator;
|
||||
Renderer renderer(1600, 1200);
|
||||
|
||||
// Sun (at the center)
|
||||
simulator.addBody(CelestialBody(1.989e30f, glm::dvec3(0, 0, 0), glm::dvec3(0, 0, 0)));
|
||||
double sunMass = 1.989e30;
|
||||
|
||||
// Mercury
|
||||
simulator.addBody(CelestialBody(3.285e23f, glm::dvec3(57.9e9f, 0, 0), glm::dvec3(0, 47.36e3f, 0)));
|
||||
// Sun (at the center)
|
||||
simulator.addBody(CelestialBody(sunMass, glm::dvec3(0, 0, 0), glm::dvec3(0, 0, 0), 6.96e8));
|
||||
|
||||
// Venus
|
||||
simulator.addBody(CelestialBody(4.867e24f, glm::dvec3(108.2e9f, 0, 0), glm::dvec3(0, 35.02e3f, 0)));
|
||||
// Mercury
|
||||
double mercuryDist = 57.9e9;
|
||||
simulator.addBody(CelestialBody(3.285e23, glm::dvec3(mercuryDist, 0, 0), calculateOrbitalVelocity(sunMass, mercuryDist), 2.44e6));
|
||||
|
||||
// Venus
|
||||
double venusDist = 108.2e9;
|
||||
simulator.addBody(CelestialBody(4.867e24, glm::dvec3(venusDist, 0, 0), calculateOrbitalVelocity(sunMass, venusDist), 6.05e6));
|
||||
|
||||
// Earth
|
||||
double earthDist = 149.6e9;
|
||||
simulator.addBody(CelestialBody(5.972e24, glm::dvec3(earthDist, 0, 0), calculateOrbitalVelocity(sunMass, earthDist), 6.37e6));
|
||||
|
||||
// Mars
|
||||
double marsDist = 227.9e9;
|
||||
simulator.addBody(CelestialBody(6.39e23, glm::dvec3(marsDist, 0, 0), calculateOrbitalVelocity(sunMass, marsDist), 3.39e6));
|
||||
|
||||
// Jupiter
|
||||
double jupiterDist = 778.5e9;
|
||||
simulator.addBody(CelestialBody(1.898e27, glm::dvec3(jupiterDist, 0, 0), calculateOrbitalVelocity(sunMass, jupiterDist), 69.91e6));
|
||||
|
||||
// Saturn
|
||||
double saturnDist = 1.429e12;
|
||||
simulator.addBody(CelestialBody(5.683e26, glm::dvec3(saturnDist, 0, 0), calculateOrbitalVelocity(sunMass, saturnDist), 58.23e6));
|
||||
|
||||
// Uranus
|
||||
double uranusDist = 2.871e12;
|
||||
simulator.addBody(CelestialBody(8.681e25, glm::dvec3(uranusDist, 0, 0), calculateOrbitalVelocity(sunMass, uranusDist ), 25.36e6));
|
||||
|
||||
// Neptune
|
||||
double neptuneDist = 4.495e12;
|
||||
simulator.addBody(CelestialBody(1.024e26, glm::dvec3(neptuneDist, 0, 0), calculateOrbitalVelocity(sunMass, neptuneDist), 24.62e6));
|
||||
|
||||
// Pluto
|
||||
double plutoDist = 5.906e12;
|
||||
simulator.addBody(CelestialBody(1.309e22, glm::dvec3(plutoDist, 0, 0), calculateOrbitalVelocity(sunMass, plutoDist), 1.18e6));
|
||||
|
||||
// Earth
|
||||
simulator.addBody(CelestialBody(5.972e24f, glm::dvec3(149.6e9f, 0, 0), glm::dvec3(0, 29.78e3f, 0)));
|
||||
|
||||
// Mars
|
||||
simulator.addBody(CelestialBody(6.39e23f, glm::dvec3(227.9e9f, 0, 0), glm::dvec3(0, 24.07e3f, 0)));
|
||||
|
||||
const float dt = 3600.0f; // Time step of 1 hour
|
||||
|
||||
|
||||
Reference in New Issue
Block a user