feat(matrix): add C44Matrix::Scale for C3Vector

This commit is contained in:
fallenoak 2022-12-24 17:15:54 -06:00
parent 3619492e39
commit 6b14afb6bd
No known key found for this signature in database
GPG key ID: 7628F8E61AEA070D
2 changed files with 18 additions and 0 deletions

View file

@ -1,4 +1,5 @@
#include "tempest/matrix/C44Matrix.hpp"
#include "tempest/Vector.hpp"
#include <cmath>
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;

View file

@ -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);