|
|
|
|
@ -11,7 +11,6 @@ systemInit(TwoBodySystem& system, GravBody gb, OrbitalElements el)
|
|
|
|
|
system.body = gb; |
|
|
|
|
system.elements = el; |
|
|
|
|
system.ep = ellipseInitAE(el.a, el.e); |
|
|
|
|
system.e3d = ellipseInit3D(system.ep, ELLIPSE_VERT_COUNT); |
|
|
|
|
system.epsilon = orbitGetSpecificEnergy(system.ep.a, gb.mu); |
|
|
|
|
system.h = orbitGetAngularMomentum(system.ep.p, gb.mu); |
|
|
|
|
system.orbital_period = orbitGetPeriod(system.ep.a, gb.mu); |
|
|
|
|
@ -49,20 +48,6 @@ ellipseInitAE(double a, double e)
|
|
|
|
|
return ellipseInitAB(a, b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Ellipse3D |
|
|
|
|
ellipseInit3D(EllipseParameters ep, uint vert_count) |
|
|
|
|
{ |
|
|
|
|
assert(ep.a > 0 && ep.b > 0 && |
|
|
|
|
ep.a >= ep.b && |
|
|
|
|
vert_count > 0); |
|
|
|
|
|
|
|
|
|
Ellipse3D e3d = { nullptr, vert_count}; |
|
|
|
|
// TODO: need to free this allocation at some point
|
|
|
|
|
e3d.vertices = UTIL_ALLOC(vert_count, glm::vec3); |
|
|
|
|
ellipse3DUpdate(ep, e3d); |
|
|
|
|
return e3d; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
OrbitalElements |
|
|
|
|
orbitInit(double a, double e) |
|
|
|
|
{ |
|
|
|
|
@ -74,19 +59,6 @@ orbitInit(double a, double e)
|
|
|
|
|
return o; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
ellipse3DUpdate(EllipseParameters ep, Ellipse3D& e3d) |
|
|
|
|
{ |
|
|
|
|
double angle = 2 * M_PI / e3d.vert_count; |
|
|
|
|
|
|
|
|
|
for (uint i = 0; i < e3d.vert_count; i++) { |
|
|
|
|
double a = angle * i; |
|
|
|
|
// NOTE: solving for distance in polar coordinates relative to focus
|
|
|
|
|
double r = ep.a * (1 - pow(ep.e, 2)) / (1 + ep.e * cos(a)); |
|
|
|
|
e3d.vertices[i] = glm::vec3(polarToRect(a, r), 0); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// NOTE: propagate anomaly functions:
|
|
|
|
|
|