SqrMat4< V > Struct Template Reference

#include <matrix4d.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

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

Public Attributes

v1
 
v2
 
v3
 
v4
 

Static Private Member Functions

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

Friends

constexpr friend SqrMat4 operator* (ValueTypeParam s, const SqrMat4 &m)
 

Member Typedef Documentation

◆ VectorStrideType

using VectorStrideType = typename V::VectorStrideType

◆ ValueType

using ValueType = typename V::ValueType

◆ ValueTypeParam

◆ 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

◆ SqrMat4() [1/5]

constexpr SqrMat4 ( )
constexpr

Default constructor, creates an identity matrix.

◆ SqrMat4() [2/5]

constexpr SqrMat4 ( const V &  v1_in,
const V &  v2_in,
const V &  v3_in,
const V &  v4_in 
)
constexpr

Initializes matrix from individual components.

◆ SqrMat4() [3/5]

constexpr SqrMat4 ( const SqrMat4< V2 > &  m)
explicitconstexpr

Initializes matrix from another matrix.

◆ SqrMat4() [4/5]

constexpr SqrMat4 ( const Mat3< V2 > &  m)
explicitconstexpr

Initializes matrix from another matrix.

◆ SqrMat4() [5/5]

constexpr SqrMat4 ( ENUM_DONT_INITIALIZE  v)
explicitconstexpr

Skips initialization of matrix (for better speed)

Member Function Documentation

◆ SetIdentity()

constexpr void SetIdentity ( )
constexpr

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()

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

◆ operator*() [1/4]

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

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]

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

Multiplies a 4d vector by a matrix.

◆ operator*() [3/4]

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

Transforms a 3d vector by a matrix.

◆ operator*() [4/4]

constexpr SqrMat4 operator* ( ValueTypeParam  s) const
constexpr

Scales all matrix components by a scalar value.

◆ operator/()

constexpr SqrMat4 operator/ ( ValueTypeParam  s) const
constexpr

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

◆ operator+()

constexpr SqrMat4 operator+ ( const SqrMat4< V > &  m2) const
constexpr

Adds two matrices component-wise.

◆ operator-()

constexpr SqrMat4 operator- ( const SqrMat4< V > &  m2) const
constexpr

Subtracts two matrices component-wise.

◆ operator==()

constexpr BoolType operator== ( const SqrMat4< V > &  other) const
constexpr

Equality operator.

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

◆ operator!=()

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

Inequality operator.

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

◆ Det()

constexpr ValueType Det ( ) const
constexpr

Computes the determinant of this matrix.

◆ operator~()

constexpr SqrMat4 operator~ ( ) const
constexpr

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

◆ Normalize()

constexpr void Normalize ( )
constexpr

Normalizes the length of all four axes.

◆ GetNormalized()

constexpr SqrMat4 GetNormalized ( ) const
constexpr

Returns this matrix with all vectors normalized.

◆ GetTransposed()

constexpr SqrMat4 GetTransposed ( ) const
constexpr

Returns the transposed matrix.

◆ operator*=() [1/2]

constexpr SqrMat4& operator*= ( const V &  v)
constexpr

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

◆ operator*=() [2/2]

constexpr SqrMat4& operator*= ( ValueTypeParam  r)
constexpr

Scales each axis by the scalar.

◆ ToString()

String ToString ( const FormatStatement formatStatement = nullptr) const

Returns a readable string of the content.

Parameters
[in]formatStatementNullptr or additional formatting instruction. See also Formatting Floating point values.
Returns
The converted result.

◆ MAXON_OPERATOR_HASH()

constexpr MAXON_OPERATOR_HASH ( SqrMat4< V >  ,
v1  ,
v2  ,
v3  ,
v4   
)
constexpr

◆ Det3()

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

Friends And Related Function Documentation

◆ operator*

constexpr friend SqrMat4 operator* ( ValueTypeParam  s,
const SqrMat4< 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.