109#ifndef DVD_MATH_MATRICES_H_
110#define DVD_MATH_MATRICES_H_
128 explicit mat2(U
m)
noexcept;
130 explicit mat2(U m0, U m1,
131 U m2, U m3)
noexcept;
133 explicit mat2(
const U *values)
noexcept;
192 [[nodiscard]]
bool compare(
const mat2 &B,
F32 epsilon)
const noexcept;
196 [[nodiscard]]
operator T *();
197 [[nodiscard]]
operator const T *()
const;
202 [[nodiscard]] T &
element(
U8 row,
U8 column)
noexcept;
203 [[nodiscard]]
const T &
element(
U8 row,
U8 column)
const noexcept;
206 void set(U m0, U m1, U m2, U m3)
noexcept;
208 void set(
const U *matrix)
noexcept;
217 void setRow(
I32 index, U value)
noexcept;
221 void setRow(
I32 index, U x, U y)
noexcept;
227 void setCol(
I32 index, U value)
noexcept;
229 void setCol(
I32 index, U x, U y)
noexcept;
233 void zero() noexcept;
235 [[nodiscard]]
bool isIdentity() const noexcept;
238 [[nodiscard]] T
det() const noexcept;
277 explicit mat3(U
m)
noexcept;
279 explicit mat3(U m0, U m1, U m2,
281 U m6, U m7, U m8)
noexcept;
283 explicit mat3(
const U *values)
noexcept;
285 explicit mat3(
const mat2<U> &B,
bool zeroFill)
noexcept;
347 [[nodiscard]]
bool compare(
const mat3 &B,
F32 epsilon)
const noexcept;
351 [[nodiscard]]
operator T *()
noexcept;
352 [[nodiscard]]
operator const T *()
const noexcept;
357 [[nodiscard]] T &
element(
U8 row,
U8 column)
noexcept;
358 [[nodiscard]]
const T &
element(
U8 row,
U8 column)
const noexcept;
361 void set(U m0, U m1, U m2, U m3, U m4, U m5, U m6, U m7, U m8)
noexcept;
363 void set(
const U *matrix)
noexcept;
372 void setRow(
I32 index, U value)
noexcept;
376 void setRow(
I32 index, U x, U y, U z)
noexcept;
383 void setCol(
I32 index, U value)
noexcept;
385 void setCol(
I32 index, U x, U y, U z)
noexcept;
389 void zero() noexcept;
391 [[nodiscard]]
bool isIdentity() const noexcept;
396 [[nodiscard]] T
det() const noexcept;
414 void fromRotation(U x, U y, U z, Angle::RADIANS<U> angle);
424 void setScale(U x, U y, U z) noexcept;
476 mat4( U m0, U m1, U m2, U m3,
477 U m4, U m5, U m6, U m7,
478 U m8, U m9, U m10, U m11,
479 U m12, U m13, U m14, U m15 )
noexcept;
481 explicit mat4(U value)
noexcept;
483 explicit mat4(
const U *values)
noexcept;
485 explicit mat4(
const mat2<U> &B,
bool zeroFill)
noexcept;
487 explicit mat4(
const mat3<U> &B,
bool zeroFill)
noexcept;
496 explicit mat4(
const vec3<U> &translation)
noexcept;
498 explicit mat4(U translationX, U translationY, U translationZ)
noexcept;
504 explicit mat4(
const Plane<U>& reflectionPlane)
noexcept;
556 [[nodiscard]]
bool compare(
const mat4 &B,
F32 epsilon)
const noexcept;
560 [[nodiscard]]
operator T *()
noexcept;
561 [[nodiscard]]
operator const T *()
const noexcept;
566 [[nodiscard]] T &
element(
U8 row,
U8 column)
noexcept;
567 [[nodiscard]]
const T &
element(
U8 row,
U8 column)
const noexcept;
569 void set(std::initializer_list<T> matrix)
noexcept;
572 void set(U
const *matrix)
noexcept;
600 void zero() noexcept;
602 [[nodiscard]]
bool isIdentity() const noexcept;
607 [[nodiscard]] T
det() const noexcept;
628 void fromRotation(U x, U y, U z, Angle::RADIANS<U> angle) noexcept;
678 void scale(U x, U y, U z) noexcept;
698 static
void Inverse(const T* in, T* out) noexcept;
718 0.5, 0.5, 0.5, 1.0 };
723 0.5, 0.5, 0.0, 1.0 };
732 0.f, 0.f, 0.f, 0.f };
735 -1.f, -1.f, -1.f, -1.f,
736 -1.f, -1.f, -1.f, -1.f,
737 -1.f, -1.f, -1.f, -1.f };
void set(U m0, U m1, U m2, U m3) noexcept
void setCol(I32 index, vec2< U > value) noexcept
bool isIdentity() const noexcept
vec2< T > getRow(I32 index) const noexcept
bool operator!=(const mat2 &B) const noexcept
mat2 & operator+=(U f) noexcept
vec2< T > getCol(I32 index) const noexcept
mat2 operator/(U f) const noexcept
mat2 & operator+=(const mat2< U > &B) noexcept
mat2 operator+(const mat2< U > &B) const noexcept
mat2 & operator/=(const mat2< U > &B) noexcept
mat2 getTranspose() const noexcept
mat2 operator*(U f) const noexcept
mat2 operator-(U f) const noexcept
void swap(mat2 &B) noexcept
mat2 getInverseTranspose() const noexcept
void transpose() noexcept
mat2 getInverse() const noexcept
mat2 & operator-=(const mat2< U > &B) noexcept
mat2 & operator/=(U f) noexcept
mat2 & operator-=(U f) noexcept
mat2 operator*(const mat2< U > &B) const noexcept
void inverseTranspose() noexcept
T elementSum() const noexcept
bool compare(const mat2 &B, F32 epsilon) const noexcept
bool operator==(const mat2 &B) const noexcept
mat2 operator+(U f) const noexcept
T & element(U8 row, U8 column) noexcept
void setRow(I32 index, U value) noexcept
mat2 & operator*=(U f) noexcept
vec2< T > operator*(const vec2< U > v) const noexcept
mat2 & operator*=(const mat2< U > &B) noexcept
mat2 operator/(const mat2< U > &B) const noexcept
mat2 operator-(const mat2< U > &B) const noexcept
void fromZRotation(Angle::RADIANS< U > angle)
mat3 & operator*=(const mat3< U > &B) noexcept
T elementSum() const noexcept
vec3< T > getForwardDirection() const noexcept
Returns normalized(getForwardVec())
bool operator==(const mat3 &B) const noexcept
mat3 getTranspose() const noexcept
const vec3< T > & getRow(I32 index) const noexcept
void setCol(I32 index, const vec3< U > &value) noexcept
mat3 & operator+=(U f) noexcept
mat3 & operator/=(const mat3< U > &B) noexcept
T & operator[](I32 i) noexcept
vec3< T > getScaleSq() const noexcept
vec3< T > getScale() const noexcept
mat3 operator/(const mat3< U > &B) const noexcept
void setRow(I32 index, U value) noexcept
vec3< T > getRightVec() const noexcept
Alias for getCol(0)
mat3 operator+(U f) const noexcept
mat3 getInverseTranspose() const noexcept
mat3 & operator-=(const mat3< U > &B) noexcept
bool isColOrthogonal() const noexcept
mat3 operator*(U f) const noexcept
mat3 operator-(U f) const noexcept
vec3< T > getCol(I32 index) const noexcept
void fromXRotation(Angle::RADIANS< U > angle)
mat3 & operator/=(U f) noexcept
T & element(U8 row, U8 column) noexcept
bool operator!=(const mat3 &B) const noexcept
mat3 operator/(U f) const noexcept
bool isUniformScale(F32 tolerance=0.0001f) const noexcept
void setScale(U x, U y, U z) noexcept
mat3 & operator*=(U f) noexcept
void set(U m0, U m1, U m2, U m3, U m4, U m5, U m6, U m7, U m8) noexcept
bool compare(const mat3 &B, F32 epsilon) const noexcept
vec2< U > operator*(const vec2< U > v) const noexcept
void inverseTranspose() noexcept
mat3 operator+(const mat3< U > &B) const noexcept
mat3 & operator+=(const mat3< U > &B) noexcept
vec3< T > getRightDirection() const noexcept
Returns normalized(getRightVec())
bool isIdentity() const noexcept
void transpose() noexcept
mat3 getInverse() const noexcept
vec3< T > getForwardVec() const noexcept
Alias for -getCol(2). Assumes -Z fwd.
mat3 operator-(const mat3< U > &B) const noexcept
mat3 & operator-=(U f) noexcept
vec3< T > getUpDirection() const noexcept
Returns normalized(getUpVec())
void fromRotation(const vec3< U > &v, Angle::RADIANS< U > angle)
vec3< T > getUpVec() const noexcept
Alias for getCol(1)
mat3 operator*(const mat3< U > &B) const noexcept
void swap(mat3 &B) noexcept
void fromYRotation(Angle::RADIANS< U > angle)
vec3< T > getForwardDirection() const noexcept
Returns normalized(getForwardVec())
vec3< T > getScaleSq() const noexcept
void setRow(I32 index, U x, U y, U z, U w) noexcept
vec3< T > getForwardVec() const noexcept
Alias for -getCol(2). Assumes -Z fwd.
T & element(U8 row, U8 column) noexcept
void swap(mat4 &B) noexcept
void setCol(I32 index, const vec4< U > &value) noexcept
mat4 getTransposeRotation() const noexcept
void inverseTranspose() noexcept
bool isUniformScale(F32 tolerance=0.0001f) const noexcept
void setCol(I32 index, U value) noexcept
void set(const mat3< U > &matrix) noexcept
vec3< T > getTranslation() const noexcept
const mat4 & reflect(U x, U y, U z, U w) noexcept
vec3< T > getUpDirection() const noexcept
Returns normalized(getUpVec())
mat4 transposeRotation() const noexcept
void setRow(I32 index, U value) noexcept
T elementSum() const noexcept
mat4 operator*(U f) const noexcept
vec2< U > operator*(const vec2< U > v) const noexcept
mat4 & operator*=(U f) noexcept
mat4 & operator*=(const mat4< U > &matrix) noexcept
void setCol(I32 index, U x, U y, U z, U w) noexcept
mat4 getInverse() const noexcept
mat4 operator+(U f) const noexcept
void fromXRotation(Angle::RADIANS< U > angle) noexcept
T & operator[](I32 i) noexcept
mat4 operator*(const mat4< U > &matrix) const noexcept
void transpose() noexcept
bool compare(const mat4< U > &B, F32 epsilon) const noexcept
mat4 operator-(U f) const noexcept
bool isIdentity() const noexcept
void set(const mat4< U > &matrix) noexcept
vec3< T > getRightVec() const noexcept
Alias for getCol(0)
static mat4< T > Multiply(const mat4< T > &matrixA, const mat4< T > &matrixB) noexcept
ret = A * B
void extractMat3(mat3< U > &matrix3) const noexcept
bool operator==(const mat4 &B) const noexcept
void fromZRotation(Angle::RADIANS< U > angle) noexcept
vec3< U > operator*(const vec3< U > &v) const noexcept
vec3< U > transformHomogeneous(const vec3< U > &v) const
vec3< T > getRightDirection() const noexcept
Returns normalized(getRightVec())
void setScale(U x, U y, U z) noexcept
void fromRotation(U x, U y, U z, Angle::RADIANS< U > angle) noexcept
void setRow(I32 index, const vec4< U > &value) noexcept
void fromYRotation(Angle::RADIANS< U > angle) noexcept
static void Inverse(const T *in, T *out) noexcept
const vec4< T > & getRow(I32 index) const noexcept
void setTranslation(const vec3< U > &v) noexcept
vec3< T > getUpVec() const noexcept
Alias for getCol(1)
mat4 & operator-=(U f) noexcept
vec3< U > transformNonHomogeneous(const vec3< U > &v) const noexcept
mat4 & operator/=(U f) noexcept
mat4 & operator/=(const mat4< U > &matrix) noexcept
mat4 operator/(const mat4< U > &matrix) const noexcept
void orthoNormalize() noexcept
void set(std::initializer_list< T > matrix) noexcept
mat4 operator-(const mat4< U > &matrix) const noexcept
vec4< U > operator*(const vec4< U > &v) const noexcept
mat4 & operator+=(const mat4< U > &matrix) noexcept
mat4 & operator-=(const mat4< U > &matrix) noexcept
mat4 & operator+=(U f) noexcept
void translate(const vec3< U > &v) noexcept
mat4 getInverseTranspose() const noexcept
vec3< T > getScale() const noexcept
vec3< U > transform(const vec3< U > &v, bool homogeneous) const
vec4< T > getCol(I32 index) const noexcept
bool compare(const mat4 &B, F32 epsilon) const noexcept
mat4 getTranspose() const noexcept
void set(U const *matrix) noexcept
mat4 operator+(const mat4< U > &matrix) const noexcept
void scale(const vec3< U > &v) noexcept
mat4 operator/(U f) const noexcept
void set(const mat2< U > &matrix) noexcept
bool operator!=(const mat4 &B) const noexcept
bool isColOrthogonal() const noexcept
Handle console commands that start with a forward slash.
static const mat3< F32 > MAT3_IDENTITY
static const mat4< F32 > MAT4_BIAS_ZERO_ONE_Z
static const mat2< F32 > MAT2_ZERO
static const mat4< F32 > MAT4_BIAS_NEGATIVE_ONE_Z
static const mat4< F32 > MAT4_NEGATIVE_ONE
static const mat2< F32 > MAT2_IDENTITY
static const mat4< F32 > MAT4_INITIAL_TRANSFORM
static const mat4< F32 > MAT4_ZERO
static const mat4< F32 > MAT4_IDENTITY
static const mat3< F32 > MAT3_ZERO