From 214f54fe89fa5de14da90efccdbf526dbcd864d2 Mon Sep 17 00:00:00 2001 From: David Allemang Date: Fri, 10 Jan 2020 16:09:01 -0500 Subject: [PATCH] add basic 4d rotation matrix utility --- vis/include/mirror.hpp | 9 +++++++++ vis/src/main.cpp | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/vis/include/mirror.hpp b/vis/include/mirror.hpp index 291cebc..11f1e92 100644 --- a/vis/include/mirror.hpp +++ b/vis/include/mirror.hpp @@ -105,3 +105,12 @@ std::vector plane_intersections(std::vector normals) { return results; } + +glm::mat4 utilRotate(const int u, const int v, const float theta) { + auto res = glm::identity(); + res[u][u] = std::cos(theta); + res[u][v] = std::sin(theta); + res[v][u] = -std::sin(theta); + res[v][v] = std::cos(theta); + return res; +} \ No newline at end of file diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 920a033..aa2fbb7 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -92,11 +92,14 @@ int main(int argc, char *argv[]) { glm::mat4 proj = glm::ortho(-pwidth, pwidth, -pheight, pheight, -100.0f, 100.0f); glUniformMatrix4fv(0, 1, false, glm::value_ptr(proj)); - auto t = (float) glfwGetTime() / 3; + auto t = (float) glfwGetTime() / 5; auto view = glm::identity(); - view = glm::rotate(view, t / 1, glm::vec3(0, 1, 0)); - view = glm::rotate(view, t / 3, glm::vec3(0, 0, 1)); - view = glm::rotate(view, t / 4, glm::vec3(1, 0, 0)); + view *= utilRotate(0, 1, t * 0.7f); + view *= utilRotate(0, 2, t * 0.8f); + view *= utilRotate(0, 3, t * 1.0f); + view *= utilRotate(1, 2, -t * 1.1f); + view *= utilRotate(1, 3, -t * 0.3f); + view *= utilRotate(2, 3, -t * 1.2f); glUniformMatrix4fv(1, 1, false, glm::value_ptr(view)); //endregion