XII Release 0.1.0
Loading...
Searching...
No Matches
xiiMat4Template< Type > Class Template Reference

A 4x4 component matrix class. More...

#include <Mat4.h>

Public Types

using ComponentType = Type
 

Public Member Functions

 XII_DECLARE_POD_TYPE ()
 
XII_ALWAYS_INLINE Type & Element (xiiInt32 iColumn, xiiInt32 iRow)
 
XII_ALWAYS_INLINE Type Element (xiiInt32 iColumn, xiiInt32 iRow) const
 
 xiiMat4Template ()
 Default Constructor DOES NOT INITIALIZE the matrix, at all.
 
 xiiMat4Template (const Type *const pData, xiiMatrixLayout::Enum layout)
 Copies 16 values from pData into the matrix. Can handle the data in row-major or column-major order.
 
 xiiMat4Template (Type c1r1, Type c2r1, Type c3r1, Type c4r1, Type c1r2, Type c2r2, Type c3r2, Type c4r2, Type c1r3, Type c2r3, Type c3r3, Type c4r3, Type c1r4, Type c2r4, Type c3r4, Type c4r4)
 Sets each element manually: Naming is "column-n row-m".
 
 xiiMat4Template (const xiiMat3Template< Type > &mRotation, const xiiVec3Template< Type > &vTranslation)
 Creates a transformation matrix from a rotation and a translation.
 
void GetAsArray (Type *out_pData, xiiMatrixLayout::Enum layout) const
 Copies the 16 values of this matrix into the given array. 'layout' defines whether the data should end up in column-major or row-major format.
 
void SetTransformationMatrix (const xiiMat3Template< Type > &mRotation, const xiiVec3Template< Type > &vTranslation)
 Sets a transformation matrix from a rotation and a translation.
 
void SetZero ()
 Sets all elements to zero.
 
void SetIdentity ()
 Sets all elements to zero, except the diagonal, which is set to one.
 
void Transpose ()
 Transposes this matrix.
 
const xiiMat4Template< Type > GetTranspose () const
 Returns the transpose of this matrix.
 
xiiResult Invert (Type fEpsilon=xiiMath::SmallEpsilon< Type >())
 Inverts this matrix. Return value indicates whether the matrix could be inverted.
 
const xiiMat4Template< Type > GetInverse (Type fEpsilon=xiiMath::SmallEpsilon< Type >()) const
 Returns the inverse of this matrix.
 
bool IsZero (Type fEpsilon=xiiMath::DefaultEpsilon< Type >()) const
 Checks whether all elements are zero.
 
bool IsIdentity (Type fEpsilon=xiiMath::DefaultEpsilon< Type >()) const
 Checks whether this is an identity matrix.
 
bool IsValid () const
 Checks whether all components are finite numbers.
 
bool IsNaN () const
 Checks whether any component is NaN.
 
xiiVec4Template< Type > GetRow (xiiUInt32 uiRow) const
 Returns all 4 components of the i-th row.
 
void SetRow (xiiUInt32 uiRow, const xiiVec4Template< Type > &vRow)
 Sets all 4 components of the i-th row.
 
xiiVec4Template< Type > GetColumn (xiiUInt32 uiColumn) const
 Returns all 4 components of the i-th column.
 
void SetColumn (xiiUInt32 uiColumn, const xiiVec4Template< Type > &vColumn)
 Sets all 4 components of the i-th column.
 
xiiVec4Template< Type > GetDiagonal () const
 Returns all 4 components on the diagonal of the matrix.
 
void SetDiagonal (const xiiVec4Template< Type > &vDiag)
 Sets all 4 components on the diagonal of the matrix.
 
const xiiVec3Template< Type > GetTranslationVector () const
 Returns the first 3 components of the last column.
 
void SetTranslationVector (const xiiVec3Template< Type > &v)
 Sets the first 3 components of the last column.
 
void SetRotationalPart (const xiiMat3Template< Type > &mRotation)
 Sets the 3x3 rotational part of the matrix.
 
const xiiMat3Template< Type > GetRotationalPart () const
 Returns the 3x3 rotational and scaling part of the matrix.
 
const xiiVec3Template< Type > GetScalingFactors () const
 Returns the 3 scaling factors that are encoded in the matrix.
 
xiiResult SetScalingFactors (const xiiVec3Template< Type > &vXYZ, Type fEpsilon=xiiMath::DefaultEpsilon< Type >())
 Tries to set the three scaling factors in the matrix. Returns XII_FAILURE if the matrix columns cannot be normalized and thus no rescaling is possible.
 
const xiiVec3Template< Type > TransformPosition (const xiiVec3Template< Type > &v) const
 Matrix-vector multiplication, assuming the 4th component of the vector is one (default behavior).
 
void TransformPosition (xiiVec3Template< Type > *pV, xiiUInt32 uiNumVectors, xiiUInt32 uiStride=sizeof(xiiVec3Template< Type >)) const
 Matrix-vector multiplication, assuming the 4th component of the vector is one (default behavior).
 
const xiiVec3Template< Type > TransformDirection (const xiiVec3Template< Type > &v) const
 Matrix-vector multiplication, assuming the 4th component of the vector is zero. So, rotation/scaling only. Useful as an optimization.
 
void TransformDirection (xiiVec3Template< Type > *pV, xiiUInt32 uiNumVectors, xiiUInt32 uiStride=sizeof(xiiVec3Template< Type >)) const
 Matrix-vector multiplication, assuming the 4th component of the vector is zero. So, rotation/scaling only. Useful as an optimization.
 
const xiiVec4Template< Type > Transform (const xiiVec4Template< Type > &v) const
 Matrix-vector multiplication.
 
void Transform (xiiVec4Template< Type > *pV, xiiUInt32 uiNumVectors, xiiUInt32 uiStride=sizeof(xiiVec4Template< Type >)) const
 Matrix-vector multiplication.
 
void operator*= (Type f)
 Component-wise multiplication (commutative)
 
void operator/= (Type f)
 Component-wise division.
 
bool IsIdentical (const xiiMat4Template< Type > &rhs) const
 Equality Check.
 
bool IsEqual (const xiiMat4Template< Type > &rhs, Type fEpsilon) const
 Equality Check with epsilon.
 

Static Public Member Functions

static xiiMat4Template< Type > MakeZero ()
 Returns a zero matrix.
 
static xiiMat4Template< Type > MakeIdentity ()
 Returns an identity matrix.
 
static xiiMat4Template< Type > MakeFromRowMajorArray (const Type *const pData)
 Creates a matrix from 16 values that are in row-major layout.
 
static xiiMat4Template< Type > MakeFromColumnMajorArray (const Type *const pData)
 Creates a matrix from 16 values that are in column-major layout.
 
static xiiMat4Template< Type > MakeFromValues (Type c1r1, Type c2r1, Type c3r1, Type c4r1, Type c1r2, Type c2r2, Type c3r2, Type c4r2, Type c1r3, Type c2r3, Type c3r3, Type c4r3, Type c1r4, Type c2r4, Type c3r4, Type c4r4)
 Creates a matrix from 16 values. Naming is "column-n row-m".
 
static xiiMat4Template< Type > MakeTranslation (const xiiVec3Template< Type > &vTranslation)
 Creates a matrix with all zero values, except the last column, which is set to x, y, z, 1.
 
static xiiMat4Template< Type > MakeTransformation (const xiiMat3Template< Type > &mRotation, const xiiVec3Template< Type > &vTranslation)
 Creates a transformation matrix from a rotation and a translation.
 
static xiiMat4Template< Type > MakeScaling (const xiiVec3Template< Type > &vScale)
 Creates a matrix with all zero values, except along the diagonal, which is set to x, y, z, 1.
 
static xiiMat4Template< Type > MakeRotationX (xiiAngleTemplate< Type > angle)
 Creates a matrix that is a rotation matrix around the X-axis.
 
static xiiMat4Template< Type > MakeRotationY (xiiAngleTemplate< Type > angle)
 Creates a matrix that is a rotation matrix around the Y-axis.
 
static xiiMat4Template< Type > MakeRotationZ (xiiAngleTemplate< Type > angle)
 Creates a matrix that is a rotation matrix around the Z-axis.
 
static xiiMat4Template< Type > MakeAxisRotation (const xiiVec3Template< Type > &vAxis, xiiAngleTemplate< Type > angle)
 Creates a matrix that is a rotation matrix around the given axis.
 

Public Attributes

Type m_fElementsCM [16]
 The matrix as a 16-element Type array (column-major)
 

Detailed Description

template<typename Type>
class xiiMat4Template< Type >

A 4x4 component matrix class.

Constructor & Destructor Documentation

◆ xiiMat4Template()

template<typename Type>
xiiMat4Template< Type >::xiiMat4Template ( const Type *const pData,
xiiMatrixLayout::Enum layout )

Copies 16 values from pData into the matrix. Can handle the data in row-major or column-major order.

Parameters
pDataThe array of Type values from which to set the matrix data.
layoutThe layout in which pData stores the matrix. The data will get transposed, if necessary. The data should be in column-major format, if you want to prevent unnecessary transposes.

The documentation for this class was generated from the following files: