Browse Source

apply elements.nu as satellite true anomaly on init

main
cinnaboot 4 years ago
parent
commit
f466aae7e6
  1. 8
      src/main.cpp
  2. 6
      src/orbits.cpp

8
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;
}

6
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

Loading…
Cancel
Save