SqMat2< V > Struct Template Reference

#include <matrix2d.h>

Detailed Description

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

General 2×2 matrix template consisting of two column vectors v1, v2.

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

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

Static Public Member Functions

static const SqMat2NullValue ()
 

Public Attributes

v1
 
v2
 

Friends

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

◆ SqMat2() [1/4]

SqMat2 ( )

Default constructor, creates an identity matrix.

◆ SqMat2() [2/4]

SqMat2 ( const V &  v1_in,
const V &  v2_in 
)

Initializes matrix from individual components.

◆ SqMat2() [3/4]

SqMat2 ( const SqMat2< V2 > &  m)
explicit

Initializes matrix from another matrix.

◆ SqMat2() [4/4]

SqMat2 ( 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.

◆ operator*() [1/3]

SqMat2<typename MultiplicativePromotion<V, typename V2::ValueType>::type> operator* ( const SqMat2< 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]

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

Transforms a point by a matrix.

◆ operator*() [3/3]

SqMat2 operator* ( ValueTypeParam  s) const

Scales all matrix components by a scalar value.

◆ operator/()

SqMat2 operator/ ( ValueTypeParam  s) const

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

◆ operator+()

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

Adds two matrices component-wise.

◆ operator-()

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

Subtracts two matrices component-wise.

◆ operator==()

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

Equality operator.

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

◆ operator!=()

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

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

SqMat2 GetNormalized ( ) const

Returns this matrix with all axis vectors normalized.

◆ operator*=() [1/2]

SqMat2& operator*= ( const V &  v)

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

◆ operator*=() [2/2]

SqMat2& 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 SqMat2& 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*

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