Mat2< V > Struct Template Reference

#include <matrix2d.h>

Detailed Description

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

General 2d Matrix template. The matrix has a dimension of 3×3 and consists of three rows and three columns. The first row is always "1, 0, 0" and not stored in the class, which means that there are 6 actual numbers used. These numbers are grouped into three vectors, one for the remaining numbers in each column. The three vectors are called off, v1 and v2, together these three vectors can be used to represent the coordinate system. A coordinate system consists of two axes, one for each coordinate (X and Y). The system also has a base position, from which the two axes originate. This base position is stored in off, and the two axis vectors are stored in v1 and v2 respectively

Public Types

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

Public Member Functions

constexpr Mat2 ()
 
constexpr Mat2 (const V &off_in, const V &v1_in, const V &v2_in)
 
constexpr Mat2 (const V &off_in, const SqrMat2< V > &mat_in)
 
constexpr MAXON_IMPLICIT Mat2 (const SqrMat2< V > &mat_in)
 
template<typename V2 >
constexpr Mat2 (const Mat2< V2 > &m)
 
constexpr Mat2 (ENUM_DONT_INITIALIZE v)
 
constexpr void SetIdentity ()
 
template<typename V2 >
constexpr Mat2< typename MultiplicativePromotion< V, typename V2::ValueType >::typeoperator* (const Mat2< V2 > &m2) const
 
template<typename V2 >
constexpr Mat2< typename MultiplicativePromotion< V, typename V2::ValueType >::typeoperator* (const SqrMat2< V2 > &m2) const
 
template<typename T , Int S>
constexpr Vec2< typename MultiplicativePromotion< ValueType, T >::type, 1 > operator* (const Vec2< T, S > &v) const
 
constexpr Mat2 operator* (ValueTypeParam s) const
 
constexpr Mat2 operator/ (ValueTypeParam s) const
 
constexpr BoolType operator== (const Mat2 &other) const
 
constexpr BoolType operator!= (const Mat2 &other) const
 
constexpr Mat2 operator~ () const
 
constexpr Mat2 GetNormalized () const
 
String ToString (const FormatStatement *formatStatement=nullptr) const
 
constexpr MAXON_OPERATOR_HASH (Mat2, sqmat, off)
 

Public Attributes

off
 
SqrMat2< V > sqmat
 

Friends

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

Member Typedef Documentation

◆ 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

◆ Mat2() [1/6]

constexpr Mat2 ( )
constexpr

Default constructor, creates an identity matrix.

◆ Mat2() [2/6]

constexpr Mat2 ( const V &  off_in,
const V &  v1_in,
const V &  v2_in 
)
constexpr

Initializes matrix from individual components.

◆ Mat2() [3/6]

constexpr Mat2 ( const V &  off_in,
const SqrMat2< V > &  mat_in 
)
constexpr

Initializes matrix from individual components.

◆ Mat2() [4/6]

constexpr MAXON_IMPLICIT Mat2 ( const SqrMat2< V > &  mat_in)
constexpr

Initializes matrix from square matrix. The translation part is initialized to zero.

◆ Mat2() [5/6]

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

Initializes matrix from another matrix.

◆ Mat2() [6/6]

constexpr Mat2 ( 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/4]

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

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/4]

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

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*() [3/4]

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

Transforms a point by a matrix.

◆ operator*() [4/4]

constexpr Mat2 operator* ( ValueTypeParam  s) const
constexpr

Scales all matrix components by a scalar value.

◆ operator/()

constexpr Mat2 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 BoolType operator== ( const Mat2< 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 Mat2< V > &  other) const
constexpr

Inequality operator.

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

◆ operator~()

constexpr Mat2 operator~ ( ) const
constexpr

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

◆ GetNormalized()

constexpr Mat2 GetNormalized ( ) const
constexpr

Returns this matrix with all axis vectors normalized.

◆ 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 ( Mat2< V >  ,
sqmat  ,
off   
)
constexpr

Friends And Related Function Documentation

◆ operator*

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

Scales all matrix components by a scalar value.

Member Data Documentation

◆ off

V off

The translation vector.

◆ sqmat

SqrMat2<V> sqmat

The 2×2 matrix for rotation, scale and shear.