SqMat4< V > Struct Template Reference

#include <vector.h>

Public Types

using VectorStrideType = typename V::VectorStrideType
 
using ValueType = typename V::ValueType
 
using ValueTypeParam = typename ByValueParam< ValueType >::type
 
using BoolType = typename V::BoolType
 

Public Member Functions

 SqMat4 ()
 
 SqMat4 (const V &v1_in, const V &v2_in, const V &v3_in, const V &v4_in)
 
template<typename V2 >
 SqMat4 (const SqMat4< V2 > &m)
 
template<typename V2 >
 SqMat4 (const Mat3< V2 > &m)
 
 SqMat4 (ENUM_DONT_INITIALIZE v)
 
void SetIdentity ()
 
V & operator[] (Int idx)
 
const V & operator[] (Int idx) const
 
Mat3< Vec3< ValueType, 1 > > GetMatrix3d ()
 
template<typename V2 >
SqMat4< typename MultiplicativePromotion< V, typename V2::ValueType >::type > operator* (const SqMat4< V2 > &m2) const
 
template<typename T , Int S>
Vec4< typename MultiplicativePromotion< ValueType, T >::type, 1 > operator* (const Vec4< T, S > &v) const
 
template<typename T , Int S>
Vec3< typename MultiplicativePromotion< ValueType, T >::type, 1 > operator* (const Vec3< T, S > &v) const
 
SqMat4 operator* (ValueTypeParam s) const
 
SqMat4 operator/ (ValueTypeParam s) const
 
SqMat4 operator+ (const SqMat4 &m2) const
 
SqMat4 operator- (const SqMat4 &m2) const
 
BoolType operator== (const SqMat4 &other) const
 
BoolType operator!= (const SqMat4 &other) const
 
ValueType Det () const
 
SqMat4 operator~ () const
 
void Normalize ()
 
SqMat4 GetNormalized () const
 
SqMat4 GetTransposed () const
 
SqMat4 & operator*= (const V &v)
 
SqMat4 & operator*= (ValueTypeParam r)
 
String ToString (const FormatStatement *formatStatement) const
 
UInt GetHashCode () const
 

Static Public Member Functions

static const SqMat4 & NullValue ()
 

Public Attributes

V v1
 
V v2
 
V v3
 
V v4
 

Static Private Member Functions

static ValueType Det3 (ValueType a1, ValueType a2, ValueType a3, ValueType b1, ValueType b2, ValueType b3, ValueType c1, ValueType c2, ValueType c3)
 

Friends

SqMat4 operator* (ValueTypeParam s, const SqMat4 &m)
 

Member Typedef Documentation

◆ VectorStrideType

using VectorStrideType = typename V::VectorStrideType

◆ ValueType

using ValueType = typename V::ValueType

◆ ValueTypeParam

using ValueTypeParam = typename ByValueParam<ValueType>::type

◆ BoolType

using BoolType = typename V::BoolType

The type returned by comparisons. If the template argument for V is a vector of SIMD components, this will be a SIMD type, too, which contains the per-element results.

Constructor & Destructor Documentation

◆ SqMat4() [1/5]

SqMat4 ( )

Default constructor, creates an identity matrix.

◆ SqMat4() [2/5]

SqMat4 ( const V &  v1_in,
const V &  v2_in,
const V &  v3_in,
const V &  v4_in 
)

Initializes matrix from individual components.

◆ SqMat4() [3/5]

SqMat4 ( const SqMat4< V2 > &  m)
explicit

Initializes matrix from another matrix.

◆ SqMat4() [4/5]

SqMat4 ( const Mat3< V2 > &  m)
explicit

Initializes matrix from another matrix.

◆ SqMat4() [5/5]

SqMat4 ( ENUM_DONT_INITIALIZE  v)
explicit

Skips initialization of matrix (for better speed)

Member Function Documentation

◆ SetIdentity()

void SetIdentity ( )

Sets this matrix to an identity matrix.

◆ operator[]() [1/2]

V& operator[] ( Int  idx)

Array (subscript) operator for index access to the matrix components.

Parameters
[in]idxElement index (if it's out of bounds you will get an error in debug code only, otherwise it will crash).
Returns
Matrix component.

◆ operator[]() [2/2]

const V& operator[] ( Int  idx) const

Array (subscript) operator for const index access to the matrix components.

Parameters
[in]idxElement index (if it's out of bounds you will get an error in debug code only, otherwise it will crash).
Returns
Matrix component.

◆ GetMatrix3d()

Mat3<Vec3<ValueType, 1> > GetMatrix3d ( )

◆ operator*() [1/4]

SqMat4<typename MultiplicativePromotion<V, typename V2::ValueType>::type> operator* ( const SqMat4< V2 > &  m2) const

Multiplies two matrices. The rule is m1 AFTER m2 If you transform a vector with the result matrix this is identical to first transforming with m2 and then with m1

◆ operator*() [2/4]

Vec4<typename MultiplicativePromotion<ValueType, T>::type, 1> operator* ( const Vec4< T, S > &  v) const

Multiplies a 4d vector by a matrix.

◆ operator*() [3/4]

Vec3<typename MultiplicativePromotion<ValueType, T>::type, 1> operator* ( const Vec3< T, S > &  v) const

Transforms a 3d vector by a matrix.

◆ operator*() [4/4]

SqMat4 operator* ( ValueTypeParam  s) const

Scales all matrix components by a scalar value.

◆ operator/()

SqMat4 operator/ ( ValueTypeParam  s) const

Divides all matrix components by a scalar value. If s is 0.0 an identity matrix will be returned.

◆ operator+()

SqMat4 operator+ ( const SqMat4< V > &  m2) const

Adds two matrices component-wise.

◆ operator-()

SqMat4 operator- ( const SqMat4< V > &  m2) const

Subtracts two matrices component-wise.

◆ operator==()

BoolType operator== ( const SqMat4< V > &  other) const

Equality operator.

Parameters
[in]otherComparison matrix.
Returns
True if this and other are equal, otherwise false.

◆ operator!=()

BoolType operator!= ( const SqMat4< V > &  other) const

Inequality operator.

Parameters
[in]otherComparison matrix.
Returns
False if this and other are equal, otherwise true.

◆ Det()

ValueType Det ( ) const

Computes the determinant of this matrix.

◆ operator~()

SqMat4 operator~ ( ) const

Calculates the inverse matrix If no inverse can be calculated the result is the Identity matrix

◆ Normalize()

void Normalize ( )

Normalizes the length of all four axes.

◆ GetNormalized()

SqMat4 GetNormalized ( ) const

Returns this matrix with all vectors normalized.

◆ GetTransposed()

SqMat4 GetTransposed ( ) const

Returns the transposed matrix.

◆ operator*=() [1/2]

SqMat4& operator*= ( const V &  v)

Scales each axis by the respective components of the passed vector.

◆ operator*=() [2/2]

SqMat4& operator*= ( ValueTypeParam  r)

Scales each axis by the scalar.

◆ ToString()

String ToString ( const FormatStatement *  formatStatement) const

Returns a readable string of the content.

Parameters
[in]formatStatementNullptr or additional formatting instruction. See also format_float.
Returns
The converted result.

◆ GetHashCode()

UInt GetHashCode ( ) const

Returns the hash code of the matrix (used for hash maps and comparisons).

Returns
The matrix' hash code.

◆ NullValue()

static const SqMat4& NullValue ( )
static

Returns a null value of the matrix (see nullvalue.h for more details).

Returns
A null value of the matrix.

◆ Det3()

static ValueType Det3 ( ValueType  a1,
ValueType  a2,
ValueType  a3,
ValueType  b1,
ValueType  b2,
ValueType  b3,
ValueType  c1,
ValueType  c2,
ValueType  c3 
)
staticprivate

Friends And Related Function Documentation

◆ operator*

SqMat4 operator* ( ValueTypeParam  s,
const SqMat4< V > &  m 
)
friend

Scales all matrix components by a scalar value.

Member Data Documentation

◆ v1

V v1

The X axis.

◆ v2

V v2

The Y axis.

◆ v3

V v3

The Z axis.

◆ v4

V v4

The W axis.