mirror of
https://github.com/thunderbrewhq/typhoon.git
synced 2025-12-12 10:32:29 +00:00
feat(vector): add operator* for C3Vector and C44Matrix
This commit is contained in:
parent
e960598699
commit
3619492e39
2 changed files with 13 additions and 0 deletions
|
|
@ -1,5 +1,6 @@
|
||||||
#include "tempest/vector/C3Vector.hpp"
|
#include "tempest/vector/C3Vector.hpp"
|
||||||
#include "tempest/Math.hpp"
|
#include "tempest/Math.hpp"
|
||||||
|
#include "tempest/Matrix.hpp"
|
||||||
|
|
||||||
C3Vector& C3Vector::operator*=(float a) {
|
C3Vector& C3Vector::operator*=(float a) {
|
||||||
this->x *= a;
|
this->x *= a;
|
||||||
|
|
@ -29,6 +30,14 @@ C3Vector operator+(const C3Vector& l, const C3Vector& r) {
|
||||||
return { x, y, z };
|
return { x, y, z };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
C3Vector operator*(const C3Vector& l, const C44Matrix& r) {
|
||||||
|
float x = r.c0 * l.z + r.b0 * l.y + r.a0 * l.x + r.d0;
|
||||||
|
float y = r.c1 * l.z + r.b1 * l.y + r.a1 * l.x + r.d1;
|
||||||
|
float z = r.c2 * l.z + r.b2 * l.y + r.a2 * l.x + r.d2;
|
||||||
|
|
||||||
|
return { x, y, z };
|
||||||
|
}
|
||||||
|
|
||||||
bool operator!=(const C3Vector& l, const C3Vector& r) {
|
bool operator!=(const C3Vector& l, const C3Vector& r) {
|
||||||
return l.x != r.x || l.y != r.y || l.z != r.z;
|
return l.x != r.x || l.y != r.y || l.z != r.z;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#ifndef TEMPEST_VECTOR_C_3VECTOR_HPP
|
#ifndef TEMPEST_VECTOR_C_3VECTOR_HPP
|
||||||
#define TEMPEST_VECTOR_C_3VECTOR_HPP
|
#define TEMPEST_VECTOR_C_3VECTOR_HPP
|
||||||
|
|
||||||
|
class C44Matrix;
|
||||||
|
|
||||||
class C3Vector {
|
class C3Vector {
|
||||||
public:
|
public:
|
||||||
// Member variables
|
// Member variables
|
||||||
|
|
@ -22,6 +24,8 @@ class C3Vector {
|
||||||
|
|
||||||
C3Vector operator+(const C3Vector& l, const C3Vector& r);
|
C3Vector operator+(const C3Vector& l, const C3Vector& r);
|
||||||
|
|
||||||
|
C3Vector operator*(const C3Vector& l, const C44Matrix& r);
|
||||||
|
|
||||||
bool operator!=(const C3Vector& l, const C3Vector& r);
|
bool operator!=(const C3Vector& l, const C3Vector& r);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue