struct TMatrix3

template<typename T>

A 3x3 matrix.

Can be used for non-homogenous transformations of three dimensional vectors and points. In row major format.

Public

Constructors

TMatrix3<T>

TMatrix3<T>() = default

TMatrix3<T>

TMatrix3<T>(const TMatrix3<T> &) = default

TMatrix3<T>

constexpr TMatrix3<T>(ZeroTag)

TMatrix3<T>

constexpr TMatrix3<T>(IdentityTag)

TMatrix3<T>

constexpr TMatrix3<T>(T m00, T m01, T m02, T m10, T m11, T m12, T m20, T m21, T m22)

TMatrix3<T>

explicit TMatrix3<T>(const TQuaternion<T> &rotation)

Construct a matrix from a TQuaternion <T >.

TMatrix3<T>

explicit TMatrix3<T>(const TQuaternion<T> &rotation, const TVector3<T> &scale)

Construct a matrix that performs rotation and scale.

TMatrix3<T>

explicit TMatrix3<T>(const TVector3<T> &axis, const TRadian<T> &angle)

Construct a matrix from an angle/axis pair.

TMatrix3<T>

explicit TMatrix3<T>(const TVector3<T> &xaxis, const TVector3<T> &yaxis, const TVector3<T> &zaxis)

Construct a matrix from 3 orthonormal local axes.

TMatrix3<T>

explicit TMatrix3<T>(const TRadian<T> &xAngle, const TRadian<T> &yAngle, const TRadian<T> &zAngle)

Construct a matrix from euler angles, YXZ ordering.

TMatrix3<T>

explicit TMatrix3<T>(const TRadian<T> &xAngle, const TRadian<T> &yAngle, const TRadian<T> &zAngle, EulerAngleOrder order)

Construct a matrix from euler angles, custom ordering.

Methods

Swap

void Swap(TMatrix3<T> &other)

Swaps the contents of this matrix with another.

GetColumn

TVector3<T> GetColumn(u32 col) const

SetColumn

void SetColumn(u32 col, const TVector3<T> &vec)

Multiply

TVector3<T> Multiply(const TVector3<T> &vec) const

Transforms the given vector by this matrix and returns the newly transformed vector.

Transpose

TMatrix3<T> Transpose() const

Returns a transpose of the matrix (switched columns and rows).

Inverse

bool Inverse(TMatrix3<T> &mat, T fTolerance = (T)9.9999999999999995E-7) const

Calculates an inverse of the matrix if it exists.

mat
Resulting matrix inverse.
fTolerance
(optional) Tolerance to use when checking if determinant is zero (or near zero in this case). Zero determinant means inverse doesn't exist.

Returns: True if inverse exists, false otherwise.

Inverse

TMatrix3<T> Inverse(T fTolerance = (T)9.9999999999999995E-7) const

Calculates an inverse of the matrix if it exists.

fTolerance
(optional) Tolerance to use when checking if determinant is zero (or near zero in this case). Zero determinant means inverse doesn't exist.

Returns: Resulting matrix inverse if it exists, otherwise a zero matrix.

Determinant

T Determinant() const

Calculates the matrix determinant.

Decomposition

void Decomposition(TQuaternion<T> &rotation, TVector3<T> &scale) const

Decompose a TMatrix3 to rotation and scale.

SingularValueDecomposition

void SingularValueDecomposition(TMatrix3<T> &matL, TVector3<T> &matS, TMatrix3<T> &matR) const

Decomposes the matrix into various useful values.

matL
Unitary matrix. Columns form orthonormal bases. If your matrix is affine and doesn't use non-uniform scaling this matrix will be a conjugate transpose of the rotation part of the matrix.
matS
Singular values of the matrix. If your matrix is affine these will be scaling factors of the matrix.
matR
Unitary matrix. Columns form orthonormal bases. If your matrix is affine and doesn't use non-uniform scaling this matrix will be the rotation part of the matrix.

QDUDecomposition

void QDUDecomposition(TMatrix3<T> &matQ, TVector3<T> &vecD, TVector3<T> &vecU) const

Decomposes the matrix into a set of values.

matQ
Columns form orthonormal bases. If your matrix is affine and doesn't use non-uniform scaling this matrix will be the rotation part of the matrix.
vecD
If the matrix is affine these will be scaling factors of the matrix.
vecU
If the matrix is affine these will be shear factors of the matrix.

Orthonormalize

void Orthonormalize()

Gram-Schmidt orthonormalization (applied to columns of rotation matrix)

ToAxisAngle

void ToAxisAngle(TVector3<T> &axis, TRadian<T> &angle) const

Converts an orthonormal matrix to axis angle representation.

FromAxisAngle

void FromAxisAngle(const TVector3<T> &axis, const TRadian<T> &angle)

Creates a rotation matrix from an axis angle representation.

ToQuaternion

void ToQuaternion(TQuaternion<T> &quat) const

Converts an orthonormal matrix to TQuaternion <T > representation.

FromQuaternion

void FromQuaternion(const TQuaternion<T> &quat)

Creates a rotation matrix from a TQuaternion <T > representation.

FromAxes

void FromAxes(const TVector3<T> &xAxis, const TVector3<T> &yAxis, const TVector3<T> &zAxis)

Creates a matrix from a three axes.

ToEulerAngles

bool ToEulerAngles(TRadian<T> &xAngle, TRadian<T> &yAngle, TRadian<T> &zAngle) const

Converts an orthonormal matrix to euler angle (pitch/yaw/roll) representation.

xAngle
Rotation about x axis. (AKA Pitch)
yAngle
Rotation about y axis. (AKA Yaw)
zAngle
Rotation about z axis. (AKA Roll)

Returns: True if unique solution was found, false otherwise.

FromEulerAngles

void FromEulerAngles(const TRadian<T> &xAngle, const TRadian<T> &yAngle, const TRadian<T> &zAngle)

Creates a rotation matrix from the provided Pitch/Yaw/Roll angles.

xAngle
Rotation about x axis. (AKA Pitch)
yAngle
Rotation about y axis. (AKA Yaw)
zAngle
Rotation about z axis. (AKA Roll)

FromEulerAngles

void FromEulerAngles(const TRadian<T> &xAngle, const TRadian<T> &yAngle, const TRadian<T> &zAngle, EulerAngleOrder order)

Creates a rotation matrix from the provided Pitch/Yaw/Roll angles.

xAngle
Rotation about x axis. (AKA Pitch)
yAngle
Rotation about y axis. (AKA Yaw)
zAngle
Rotation about z axis. (AKA Roll)
order
The order in which rotations will be applied. Different rotations can be created depending on the order.

EigenSolveSymmetric

void EigenSolveSymmetric(T eigenValues[3], TVector3<T> eigenVectors[3]) const

Eigensolver, matrix must be symmetric.

Operators

operator=

TMatrix3<T> &operator=(const TMatrix3<T> &) = default

operator[]

T *operator[](u32 row) const

Returns a row of the matrix.

operator==

bool operator==(const TMatrix3<T> &rhs) const

operator!=

bool operator!=(const TMatrix3<T> &rhs) const

operator+

TMatrix3<T> operator+(const TMatrix3<T> &rhs) const

operator-

TMatrix3<T> operator-(const TMatrix3<T> &rhs) const

operator*

TMatrix3<T> operator*(const TMatrix3<T> &rhs) const

operator-

TMatrix3<T> operator-() const

operator*

TMatrix3<T> operator*(T rhs) const

Protected

Methods

Tridiagonal

void Tridiagonal(T diag[3], T subDiag[3])

QLAlgorithm

bool QLAlgorithm(T diag[3], T subDiag[3])

staticBidiagonalize

static void Bidiagonalize(TMatrix3<T> &matA, TMatrix3<T> &matL, TMatrix3<T> &matR)

staticGolubKahanStep

static void GolubKahanStep(TMatrix3<T> &matA, TMatrix3<T> &matL, TMatrix3<T> &matR)

Fields

m

T[3][3] m