diff --git a/src/renderer.cpp b/src/renderer.cpp index 8a0d81d..2b27bd0 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -239,7 +239,7 @@ void update_camera(RenderState* render_state, SimulationState* sim) { Vector3 sim_to_render(Vec3 pos, double scale) { return (Vector3){ (float)(pos.x * scale), - (float)(-pos.z * scale), + (float)(pos.z * scale), (float)(pos.y * scale) }; } diff --git a/tests/test_orbital_period.cpp b/tests/test_orbital_period.cpp index 4b76812..dab10aa 100644 --- a/tests/test_orbital_period.cpp +++ b/tests/test_orbital_period.cpp @@ -70,3 +70,33 @@ TEST_CASE("Orbital period - Mars (RK4)", "[period][rk4]") { destroy_orbit_tracker(tracker); destroy_simulation(sim); } + +TEST_CASE("Orbit direction - prograde for zero inclination", "[direction]") { + const double TIME_STEP = 60.0; + const double TEST_DURATION_DAYS = 1.0; + const double SECONDS_PER_DAY = 86400.0; + const int STEPS = (int)(TEST_DURATION_DAYS * SECONDS_PER_DAY / TIME_STEP); + + SimulationState* sim = create_simulation(2, 0, 0, TIME_STEP); + REQUIRE(load_system_config(sim, "tests/test_energy.toml")); + + CelestialBody* sun = &sim->bodies[0]; + CelestialBody* earth = &sim->bodies[1]; + + Vec3 initial_rel_pos = vec3_sub(earth->global_position, sun->global_position); + double theta_start = atan2(initial_rel_pos.y, initial_rel_pos.x); + + for (int i = 0; i < STEPS; i++) { + update_simulation(sim); + } + + Vec3 final_rel_pos = vec3_sub(earth->global_position, sun->global_position); + double theta_final = atan2(final_rel_pos.y, final_rel_pos.x); + + INFO("Initial angle: " << theta_start << " rad"); + INFO("Final angle: " << theta_final << " rad"); + + REQUIRE(theta_final > theta_start); + + destroy_simulation(sim); +}