Common: Add additional Matrix/Vec functions.

This commit is contained in:
Jordan Woyak
2019-11-05 18:42:52 -06:00
parent d8c62b5965
commit 1e028025e5
2 changed files with 23 additions and 0 deletions

View File

@ -20,6 +20,10 @@ union TVec3
TVec3() = default;
TVec3(T _x, T _y, T _z) : data{_x, _y, _z} {}
TVec3 Cross(const TVec3& rhs) const
{
return {(y * rhs.z) - (rhs.y * z), (z * rhs.x) - (rhs.z * x), (x * rhs.y) - (rhs.x * y)};
}
T Dot(const TVec3& other) const { return x * other.x + y * other.y + z * other.z; }
T LengthSquared() const { return Dot(*this); }
T Length() const { return std::sqrt(LengthSquared()); }
@ -275,6 +279,8 @@ public:
static Matrix33 RotateY(float rad);
static Matrix33 RotateZ(float rad);
static Matrix33 Rotate(float rad, const Vec3& axis);
static Matrix33 Scale(const Vec3& vec);
// set result = a x b