From c4edf127e9b8d53fffeb940820f86259d18704d0 Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Wed, 21 Aug 2024 13:30:21 +0100 Subject: [PATCH] fix: remap coordinates to make Y up --- src/main.cpp | 2 +- src/orbitvisualizer.cpp | 6 ++++++ src/particlevisualizer.cpp | 4 ++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 1b42efc..8a65103 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -99,7 +99,7 @@ int main() // TODO: implement zoom //orbit.setSemiMajorAxis(384748); // in km orbit.setEccentricity(0.055); - orbit.setInclination(5.15); // degreees + orbit.setInclination(glm::radians(5.15)); // radians? orbit.setArgumentOfPeriapsis(318.15); // in the case of the moon these last two values are orbit.setLongitudeOfAscendingNode(60.0); // pretty much constantly changing so use whatever diff --git a/src/orbitvisualizer.cpp b/src/orbitvisualizer.cpp index 096f5c5..03a4e58 100644 --- a/src/orbitvisualizer.cpp +++ b/src/orbitvisualizer.cpp @@ -29,6 +29,12 @@ void OrbitVisualizer::regenerateVertices() { float t = (float)i / (float)_vertexCount * 2.0 * _pi; glm::vec3 pos = _orbit.getPosition(t); + // Vertices come out of the library with X and Y being in the 'flat' plane. Re-order them + // here such that Z is up. + float y = pos.z; + pos.z = pos.y; + pos.y = y; + pos.z *= -1; _vertices.push_back(pos.x); _vertices.push_back(pos.y); diff --git a/src/particlevisualizer.cpp b/src/particlevisualizer.cpp index ce7a52c..9d83445 100644 --- a/src/particlevisualizer.cpp +++ b/src/particlevisualizer.cpp @@ -11,6 +11,10 @@ void ParticleVisualizer::render(float time) // TODO: get mean anomly from particle which has the mass!! const float meanAnomaly = time; glm::vec3 pos = _map.getParticlePosition(_particleId, meanAnomaly); + float y = pos.z; + pos.z = pos.y; + pos.y = y; + pos.z *= -1; // TODO: extract widget to its own visualizer since we know it wants an orbit but we // might not have one here