From f466aae7e6b03b56140af8524fd5632595906c97 Mon Sep 17 00:00:00 2001 From: cinnaboot Date: Wed, 20 Jul 2022 15:39:40 -0400 Subject: [PATCH] apply elements.nu as satellite true anomaly on init --- src/main.cpp | 8 +++----- src/orbits.cpp | 6 ++++++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 9f2187c..57d5fa7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -217,12 +217,10 @@ loadOrbit(GameState* gs, orbit->ellipse_entity = initEllipseEntity(rs, orbit, DEFAULT_ORBIT_VERTICES); setEntityPosition(orbit->ellipse_entity, vec3(0, 0, 0)); - rotateEntity(orbit->ellipse_entity, vec3(1, 0, 0), (float) M_PI / 2); orbit->satellite_entity = initSatelliteEntity(rs, sat_name); scaleEntity(orbit->satellite_entity, 1 / SCALING); - setEntityPosition(orbit->satellite_entity, - orbit->e3d.vertices[0]); + setEntityPosition(orbit->satellite_entity, orbit->system.sat.position); return orbit; } @@ -246,9 +244,9 @@ loadScene(GameState* gs, RenderState* rs) gs->coord_overlay = addCoordinateOverlay(rs); - OrbitalElements el = orbitInit(8000, 0, 0, 0, 0, 0); + OrbitalElements el = orbitInit(8000, 0, 0, 0, 0, DEG2RAD(-90)); GameOrbit* go_1 = loadOrbit(gs, rs, body, el, rg, "sat_01"); - addManeuver(go_1, ImpulseType::PROGRADE, DEG2RAD(-90), 0.4); + addManeuver(go_1, ImpulseType::PROGRADE, DEG2RAD(180), 1); return true; } diff --git a/src/orbits.cpp b/src/orbits.cpp index 5d55397..d5be426 100644 --- a/src/orbits.cpp +++ b/src/orbits.cpp @@ -17,6 +17,12 @@ systemInit(TwoBodySystem& system, GravBody gb, OrbitalElements el) system.r_periapsis = system.ep.a - system.ep.c; system.r_apoapsis = 2 * system.ep.a - system.r_periapsis; system.rotation = orbitGetXForm(el); + + system.sat.theta = el.nu; + system.sat.r = orbitGetRadialDistance(system.ep.e, system.ep.p, el.nu); + system.sat.v = orbitGetVelocity(system.epsilon, gb.mu, system.sat.r); + system.sat.position = + system.rotation * orbitGetPositionVector(system.sat.r, el.nu); } GravBody