This commit is contained in:
ElonOlsson
2019-04-30 08:36:42 -06:00
parent 7c793fd841
commit d26700268f
3 changed files with 34 additions and 4 deletions

View File

@@ -636,7 +636,7 @@ namespace openspace {
// positionAtTime.time = Time(orbit.epoch + timeOffset);
// glm::vec3 position = calculatePosition(Time(orbit.epoch + timeOffset), orbit.epoch);
glm::vec3 position = _keplerTranslator.position(Time(orbit.epoch + timeOffset));
_vertexBufferData[index].x = position.x;
_vertexBufferData[index].y = position.y;
@@ -671,6 +671,15 @@ namespace openspace {
}
// glm::dvec3 ElonsTest::calculatePosition(const Time& time, double epoch) const {
// if (_orbitPlaneDirty) {
// _keplerTranslator.computeOrbitPlane();
// _orbitPlaneDirty = false;
// }
// const double t = time.j2000Seconds() - epoch;
// }
}

View File

@@ -324,6 +324,27 @@ glm::dvec3 KeplerTranslation::debrisPos(const float& time) const {
return _orbitPlaneRotation * p;
}
// Is only used in renderableDebris so far.
glm::dvec3 KeplerTranslation::position(const Time& time) const {
if (_orbitPlaneDirty) {
computeOrbitPlane();
_orbitPlaneDirty = false;
}
const double t = time.j2000Seconds() - _epoch;
const double meanMotion = glm::two_pi<double>() / _period;
const double meanAnomaly = glm::radians(_meanAnomalyAtEpoch.value()) + t * meanMotion;
const double e = eccentricAnomaly(meanAnomaly);
// Use the eccentric anomaly to compute the actual location
const glm::dvec3 p = {
_semiMajorAxis * 1000.0 * (cos(e) - _eccentricity),
_semiMajorAxis * 1000.0 * sin(e) * sqrt(1.0 - _eccentricity * _eccentricity),
0.0
};
return _orbitPlaneRotation * p;
}
void KeplerTranslation::computeOrbitPlane() const {
// We assume the following coordinate system:
// z = axis of rotation

View File

@@ -28,6 +28,7 @@
#include <openspace/scene/translation.h>
#include <openspace/properties/scalar/doubleproperty.h>
#include <openspace/util/time.h>
#include <ghoul/glm.h>
#include <ghoul/misc/exception.h>
#include <openspace/util/time.h>
@@ -90,9 +91,8 @@ public:
*/
glm::dvec3 position(const UpdateData& data) const override;
// Is only used in renderableDebris so far. May rename if needed
glm::dvec3 debrisPos(const float& time) const;
// Is only used in renderableDebris so far.
glm::dvec3 position(const Time& time) const;
/**
* Method returning the openspace::Documentation that describes the ghoul::Dictinoary