From b17b7a18e6b271cc98bbba662e86e99ffecfb261 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 24 Dec 2022 17:24:35 -0600 Subject: [PATCH] feat(matrix): add C44Matrix::Transpose --- tempest/matrix/C44Matrix.cpp | 24 ++++++++++++++++++++++++ tempest/matrix/C44Matrix.hpp | 1 + 2 files changed, 25 insertions(+) diff --git a/tempest/matrix/C44Matrix.cpp b/tempest/matrix/C44Matrix.cpp index c8272be..098bb8b 100644 --- a/tempest/matrix/C44Matrix.cpp +++ b/tempest/matrix/C44Matrix.cpp @@ -99,6 +99,30 @@ void C44Matrix::Translate(const C3Vector& move) { this->d2 = this->a2 * move.x + this->b2 * move.y + this->c2 * move.z + this->d2; } +C44Matrix C44Matrix::Transpose() const { + float a0 = this->a0; + float a1 = this->a1; + float a2 = this->a2; + float a3 = this->a3; + + float b0 = this->b0; + float b1 = this->b1; + float b2 = this->b2; + float b3 = this->b3; + + float c0 = this->c0; + float c1 = this->c1; + float c2 = this->c2; + float c3 = this->c3; + + float d0 = this->d0; + float d1 = this->d1; + float d2 = this->d2; + float d3 = this->d3; + + return { a0, b0, c0, d0, a1, b1, c1, d1, a2, b2, c2, d2, a3, b3, c3, d3 }; +} + C44Matrix operator*(const C44Matrix& l, float a) { float a0 = l.a0 * a; float a1 = l.a1 * a; diff --git a/tempest/matrix/C44Matrix.hpp b/tempest/matrix/C44Matrix.hpp index 20364ae..1519a0d 100644 --- a/tempest/matrix/C44Matrix.hpp +++ b/tempest/matrix/C44Matrix.hpp @@ -52,6 +52,7 @@ class C44Matrix { void Scale(const C3Vector& scale); void Scale(float scale); void Translate(const C3Vector& move); + C44Matrix Transpose() const; }; C44Matrix operator*(const C44Matrix& l, float a);