refactor: remove astro references
removed from: main.cpp orbiter.cpp
This commit is contained in:
parent
a9c836dea0
commit
2059b4ed16
|
@ -9,18 +9,19 @@ typedef std::vector<float> Vector6;
|
|||
class Orbit
|
||||
{
|
||||
public:
|
||||
Orbit(const Vector6 keplerianElements);
|
||||
Orbit(float semiMajorAxis, float eccentricity, float inclination,
|
||||
float argumentOfPeriapsis, float longitudeOfAscendingNode);
|
||||
~Orbit() = default;
|
||||
|
||||
float getEccentricity() const;
|
||||
void setEccentricity(float eccentricity);
|
||||
|
||||
// TODO: meanAnomaly in all these arguments actually means eccentricMeanAnomaly,
|
||||
// will have to change that when adding non-ellipctical orbits - don't get confused!
|
||||
const glm::vec3 getPosition(const float meanAnomaly) const;
|
||||
glm::vec3 getTangent(const float meanAnomaly);
|
||||
glm::mat4 getLookAlongMatrix(const float meanAnomaly);
|
||||
|
||||
void setElements(Vector6 keplerianElements);
|
||||
void getElements(Vector6& keplerianElements) const;
|
||||
|
||||
private:
|
||||
Vector6 _keplerianElements;
|
||||
|
||||
|
|
|
@ -5,19 +5,25 @@
|
|||
|
||||
#include <glm/gtc/matrix_transform.hpp>
|
||||
|
||||
Orbit::Orbit(Vector6 keplerianElements) :
|
||||
_keplerianElements(keplerianElements)
|
||||
Orbit::Orbit(float semiMajorAxis, float eccentricity, float inclination,
|
||||
float argumentOfPeriapsis, float longitudeOfAscendingNode)
|
||||
{
|
||||
_keplerianElements.resize(6);
|
||||
_keplerianElements[astro::semiMajorAxisIndex] = semiMajorAxis;
|
||||
_keplerianElements[astro::eccentricityIndex] = eccentricity;
|
||||
_keplerianElements[astro::inclinationIndex] = inclination;
|
||||
_keplerianElements[astro::argumentOfPeriapsisIndex] = argumentOfPeriapsis;
|
||||
_keplerianElements[astro::longitudeOfAscendingNodeIndex] = semiMajorAxis;
|
||||
}
|
||||
|
||||
void Orbit::setElements(Vector6 keplerianElements)
|
||||
float Orbit::getEccentricity() const
|
||||
{
|
||||
_keplerianElements = keplerianElements;
|
||||
return _keplerianElements[astro::eccentricityIndex];
|
||||
}
|
||||
|
||||
void Orbit::getElements(Vector6& keplerianElements) const
|
||||
void Orbit::setEccentricity(float eccentricity)
|
||||
{
|
||||
keplerianElements = _keplerianElements;
|
||||
_keplerianElements[astro::eccentricityIndex] = eccentricity;
|
||||
}
|
||||
|
||||
glm::mat4 Orbit::getLookAlongMatrix(const float meanAnomaly)
|
||||
|
|
|
@ -37,7 +37,6 @@
|
|||
|
||||
#include <GL/glew.h>
|
||||
#include <GLFW/glfw3.h>
|
||||
#include <astro/stateVectorIndices.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include "gfx.hpp"
|
||||
|
@ -95,13 +94,7 @@ int main()
|
|||
// set up scene
|
||||
Icosphere planet(0.2, 3, litProgram);
|
||||
|
||||
std::vector<float> keplerianElements(6);
|
||||
keplerianElements[astro::semiMajorAxisIndex] = .75;
|
||||
keplerianElements[astro::eccentricityIndex] = .5;
|
||||
keplerianElements[astro::inclinationIndex] = 3.142 / 2.0 + 1;
|
||||
keplerianElements[astro::argumentOfPeriapsisIndex] = 2.0;
|
||||
keplerianElements[astro::longitudeOfAscendingNodeIndex] = 0;
|
||||
Orbit orbit(keplerianElements);
|
||||
Orbit orbit(.75f, .5, 3.142 / 2.0 + 1, 2.0, 0);
|
||||
OrbitVisualizer orbitVisualizer(orbit, unlitProgram);
|
||||
|
||||
Icosphere orbiterSphere(0.07, 2, litProgram);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#include "orbiter.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <astro/stateVectorIndices.hpp>
|
||||
|
||||
Orbiter::Orbiter(Icosphere& sphere, Orbit& orbit, GLuint shaderProgram) :
|
||||
_sphere(sphere),
|
||||
|
@ -28,23 +27,17 @@ void Orbiter::cycleAnimation()
|
|||
|
||||
glm::vec3 Orbiter::getPosition(const float time)
|
||||
{
|
||||
std::vector<float> keplerianElements(6);
|
||||
_orbit.getElements(keplerianElements);
|
||||
|
||||
//int animation = (int)(time/ORBITAL_PERIOD) % 2 == 1;
|
||||
|
||||
if (_animation == ANIM_ORBITING)
|
||||
return _orbit.getPosition(time);
|
||||
|
||||
// TODO: i want to modify the eccentricity of the orbit with a control,
|
||||
// not an automatic animation
|
||||
// TODO: modify the eccentricity of the orbit with a control instead
|
||||
// of an automatic animation
|
||||
if (_animation == ANIM_ECCENTRICITY)
|
||||
{
|
||||
// TODO: what are these magic numbers
|
||||
float e = .25 + .2 * sin(time);
|
||||
keplerianElements[astro::eccentricityIndex] = e;
|
||||
// TODO: extract set from getter
|
||||
_orbit.setElements(keplerianElements);
|
||||
_orbit.setEccentricity(e);
|
||||
|
||||
return _orbit.getPosition(0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue