From 6b14afb6bd77706886e771f24cd2fb6cf2006a39 Mon Sep 17 00:00:00 2001 From: fallenoak Date: Sat, 24 Dec 2022 17:15:54 -0600 Subject: [PATCH] feat(matrix): add C44Matrix::Scale for C3Vector --- tempest/matrix/C44Matrix.cpp | 15 +++++++++++++++ tempest/matrix/C44Matrix.hpp | 3 +++ 2 files changed, 18 insertions(+) diff --git a/tempest/matrix/C44Matrix.cpp b/tempest/matrix/C44Matrix.cpp index d472ca2..16f96cf 100644 --- a/tempest/matrix/C44Matrix.cpp +++ b/tempest/matrix/C44Matrix.cpp @@ -1,4 +1,5 @@ #include "tempest/matrix/C44Matrix.hpp" +#include "tempest/Vector.hpp" #include C44Matrix C44Matrix::RotationAroundZ(float angle) { @@ -64,6 +65,20 @@ void C44Matrix::RotateAroundZ(float angle) { *this = C44Matrix::RotationAroundZ(angle) * *this; } +void C44Matrix::Scale(const C3Vector& scale) { + this->a0 *= scale.x; + this->a1 *= scale.x; + this->a2 *= scale.x; + + this->b0 *= scale.y; + this->b1 *= scale.y; + this->b2 *= scale.y; + + this->c0 *= scale.z; + this->c1 *= scale.z; + this->c2 *= scale.z; +} + 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 0b59ea8..9474166 100644 --- a/tempest/matrix/C44Matrix.hpp +++ b/tempest/matrix/C44Matrix.hpp @@ -1,6 +1,8 @@ #ifndef TEMPEST_MATRIX_C_44MATRIX_HPP #define TEMPEST_MATRIX_C_44MATRIX_HPP +class C3Vector; + class C44Matrix { public: // Static functions @@ -47,6 +49,7 @@ class C44Matrix { float Determinant() const; C44Matrix Inverse(float det) const; void RotateAroundZ(float angle); + void Scale(const C3Vector& scale); }; C44Matrix operator*(const C44Matrix& l, float a);