SqMat3< V > Struct Template Reference

#include <matrix.h>

Detailed Description

template<typename V>
struct maxon::SqMat3< V >

General 3×3 matrix template consisting of three column vectors v1, v2, v3.

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

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

Static Public Member Functions

static const SqMat3NullValue ()
 

Public Attributes

v1
 
v2
 
v3
 

Friends

SqMat3 operator* (ValueTypeParam s, const SqMat3 &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

◆ SqMat3() [1/5]

SqMat3 ( )

Default constructor, creates an identity matrix.

◆ SqMat3() [2/5]

SqMat3 ( const V &  v1_in,
const V &  v2_in,
const V &  v3_in 
)

Initializes matrix from individual components.

◆ SqMat3() [3/5]

SqMat3 ( const SqMat3< V2 > &  m)
explicit

Initializes matrix from another matrix.

◆ SqMat3() [4/5]

SqMat3 ( ENUM_DONT_INITIALIZE  v)
explicit

Skips initialization of matrix (for better speed)

◆ SqMat3() [5/5]

SqMat3 ( const SqMat2< V2 > &  m)
explicit

Initializes matrix from 2d matrix. v3 is assigned Cross(v1, v2).GetNormalized()

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.

◆ operator*() [1/3]

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

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

◆ operator*() [2/3]

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

Transforms a vector by a matrix.

◆ operator*() [3/3]

SqMat3 operator* ( ValueTypeParam  s) const

Scales all matrix components by a scalar value.

◆ operator/()

SqMat3 operator/ ( ValueTypeParam  s) const

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

◆ operator+()

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

Adds two matrices component-wise.

◆ operator-()

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

Subtracts two matrices component-wise.

◆ operator==()

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

Equality operator.

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

◆ operator!=()

BoolType operator!= ( const SqMat3< 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~()

SqMat3 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 three axes.

◆ GetNormalized()

SqMat3 GetNormalized ( ) const

Returns this matrix with all axis vectors normalized.

◆ GetTransposed()

SqMat3 GetTransposed ( ) const

Returns the transposed matrix.

◆ GetScale()

V GetScale ( void  ) const

◆ GetTensorMatrix()

SqMat3 GetTensorMatrix ( ) const

Calculates the tensor matrix which allows to transform normal vectors for non-orthogonal matrices. The tensor matrix T of a matrix M is given by T = inverse(transpose(M)) * det(M), and its computation is faster than that of the inverse transpose. To transform a normal with a normalized result, use the formula transformedNormal = !(matrix.GetTensorMatrix() * normal).

◆ operator*=() [1/2]

SqMat3& operator*= ( const V &  v)

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

◆ operator*=() [2/2]

SqMat3& 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 SqMat3& NullValue ( )
static

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

Returns
A null value of the matrix.

Friends And Related Function Documentation

◆ operator*

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