MeshLib C++ Docs
Loading...
Searching...
No Matches
MR::Matrix2< T > Struct Template Reference

#include <MRMatrix2.h>

Public Types

using ValueType = T
 
using VectorType = Vector2<T>
 

Public Member Functions

constexpr Matrix2 () noexcept=default
 
constexpr Matrix2 (const Vector2< T > &x, const Vector2< T > &y)
 initializes matrix from its 2 rows
 
template<typename U >
constexpr Matrix2 (const Matrix2< U > &m)
 
constexpr const Vector2< T > & operator[] (int row) const noexcept
 row access
 
constexpr Vector2< T > & operator[] (int row) noexcept
 
constexpr Vector2< T > col (int i) const noexcept
 column access
 
constexpr T trace () const noexcept
 computes trace of the matrix
 
constexpr T normSq () const noexcept
 compute sum of squared matrix elements
 
constexpr auto norm () const noexcept
 
constexpr T det () const noexcept
 computes determinant of the matrix
 
constexpr Matrix2< T > inverse () const noexcept
 computes inverse matrix
 
constexpr Matrix2< T > transposed () const noexcept
 computes transposed matrix
 

Static Public Member Functions

static constexpr Matrix2 zero () noexcept
 
static constexpr Matrix2 identity () noexcept
 
static constexpr Matrix2 scale (T s) noexcept
 returns a matrix that scales uniformly
 
static constexpr Matrix2 scale (T sx, T sy) noexcept
 returns a matrix that has its own scale along each axis
 
static constexpr Matrix2 scale (const Vector2< T > &s) noexcept
 
static constexpr Matrix2 rotation (T angle) noexcept
 creates matrix representing rotation around origin on given angle
 
static constexpr Matrix2 rotation (const Vector2< T > &from, const Vector2< T > &to) noexcept
 creates matrix representing rotation that after application to (from) makes (to) vector
 
static constexpr Matrix2 fromRows (const Vector2< T > &x, const Vector2< T > &y) noexcept
 constructs a matrix from its 2 rows
 
static constexpr Matrix2 fromColumns (const Vector2< T > &x, const Vector2< T > &y) noexcept
 

Public Attributes

Vector2< T > x { 1, 0 }
 rows, identity matrix by default
 
Vector2< T > y { 0, 1 }
 

Friends

constexpr bool operator== (const Matrix2< T > &a, const Matrix2< T > &b)
 
constexpr bool operator!= (const Matrix2< T > &a, const Matrix2< T > &b)
 
constexpr auto operator+ (const Matrix2< T > &a, const Matrix2< T > &b) -> Matrix2< decltype(std::declval< T >()+std::declval< T >())>
 
constexpr auto operator- (const Matrix2< T > &a, const Matrix2< T > &b) -> Matrix2< decltype(std::declval< T >() - std::declval< T >())>
 
constexpr auto operator* (T a, const Matrix2< T > &b) -> Matrix2< decltype(std::declval< T >() *std::declval< T >())>
 
constexpr auto operator* (const Matrix2< T > &b, T a) -> Matrix2< decltype(std::declval< T >() *std::declval< T >())>
 
constexpr auto operator/ (Matrix2< T > b, T a) -> Matrix2< decltype(std::declval< T >()/std::declval< T >())>
 
constexpr Matrix2< T > & operator+= (Matrix2< T > &a, const Matrix2< T > &b)
 
constexpr Matrix2< T > & operator-= (Matrix2< T > &a, const Matrix2< T > &b)
 
constexpr Matrix2< T > & operator*= (Matrix2< T > &a, T b)
 
constexpr Matrix2< T > & operator/= (Matrix2< T > &a, T b)
 
constexpr auto operator* (const Matrix2< T > &a, const Vector2< T > &b) -> Vector2< decltype(dot(std::declval< Vector2< T > >(), std::declval< Vector2< T > >()))>
 x = a * b
 
constexpr auto operator* (const Matrix2< T > &a, const Matrix2< T > &b) -> Matrix2< decltype(dot(std::declval< Vector2< T > >(), std::declval< Vector2< T > >()))>
 product of two matrices
 

Related Symbols

(Note that these are not member symbols.)

template<typename T >
auto dot (const Matrix2< T > &a, const Matrix2< T > &b) -> decltype(dot(a.x, b.x))
 double-dot product: x = a : b
 
template<typename T >
Matrix2< T > outer (const Vector2< T > &a, const Vector2< T > &b)
 x = a * b^T
 

Detailed Description

template<typename T>
struct MR::Matrix2< T >

arbitrary 2x2 matrix

Member Typedef Documentation

◆ ValueType

template<typename T >
using MR::Matrix2< T >::ValueType = T

◆ VectorType

template<typename T >
using MR::Matrix2< T >::VectorType = Vector2<T>

Constructor & Destructor Documentation

◆ Matrix2() [1/3]

template<typename T >
MR::Matrix2< T >::Matrix2 ( )
constexprdefaultnoexcept

◆ Matrix2() [2/3]

template<typename T >
MR::Matrix2< T >::Matrix2 ( const Vector2< T > & x,
const Vector2< T > & y )
inlineconstexpr

initializes matrix from its 2 rows

◆ Matrix2() [3/3]

template<typename T >
template<typename U >
MR::Matrix2< T >::Matrix2 ( const Matrix2< U > & m)
inlineexplicitconstexpr

Member Function Documentation

◆ col()

template<typename T >
Vector2< T > MR::Matrix2< T >::col ( int i) const
inlineconstexprnoexcept

column access

◆ det()

template<typename T >
T MR::Matrix2< T >::det ( ) const
constexprnoexcept

computes determinant of the matrix

◆ fromColumns()

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::fromColumns ( const Vector2< T > & x,
const Vector2< T > & y )
inlinestaticconstexprnoexcept

constructs a matrix from its 2 columns; use this method to get the matrix that transforms basis vectors ( plusX, plusY ) into vectors ( x, y ) respectively

◆ fromRows()

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::fromRows ( const Vector2< T > & x,
const Vector2< T > & y )
inlinestaticconstexprnoexcept

constructs a matrix from its 2 rows

◆ identity()

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::identity ( )
inlinestaticconstexprnoexcept

◆ inverse()

template<typename T >
Matrix2< T > MR::Matrix2< T >::inverse ( ) const
constexprnoexcept

computes inverse matrix

◆ norm()

template<typename T >
auto MR::Matrix2< T >::norm ( ) const
inlineconstexprnoexcept

◆ normSq()

template<typename T >
T MR::Matrix2< T >::normSq ( ) const
inlineconstexprnoexcept

compute sum of squared matrix elements

◆ operator[]() [1/2]

template<typename T >
const Vector2< T > & MR::Matrix2< T >::operator[] ( int row) const
inlineconstexprnoexcept

row access

◆ operator[]() [2/2]

template<typename T >
Vector2< T > & MR::Matrix2< T >::operator[] ( int row)
inlineconstexprnoexcept

◆ rotation() [1/2]

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::rotation ( const Vector2< T > & from,
const Vector2< T > & to )
staticconstexprnoexcept

creates matrix representing rotation that after application to (from) makes (to) vector

◆ rotation() [2/2]

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::rotation ( T angle)
staticconstexprnoexcept

creates matrix representing rotation around origin on given angle

◆ scale() [1/3]

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::scale ( const Vector2< T > & s)
inlinestaticconstexprnoexcept

◆ scale() [2/3]

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::scale ( T s)
inlinestaticconstexprnoexcept

returns a matrix that scales uniformly

◆ scale() [3/3]

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::scale ( T sx,
T sy )
inlinestaticconstexprnoexcept

returns a matrix that has its own scale along each axis

◆ trace()

template<typename T >
T MR::Matrix2< T >::trace ( ) const
inlineconstexprnoexcept

computes trace of the matrix

◆ transposed()

template<typename T >
Matrix2< T > MR::Matrix2< T >::transposed ( ) const
constexprnoexcept

computes transposed matrix

◆ zero()

template<typename T >
static constexpr Matrix2 MR::Matrix2< T >::zero ( )
inlinestaticconstexprnoexcept

Friends And Related Symbol Documentation

◆ dot()

template<typename T >
auto dot ( const Matrix2< T > & a,
const Matrix2< T > & b ) -> decltype( dot( a.x, b.x ) )
related

double-dot product: x = a : b

◆ operator!=

template<typename T >
bool operator!= ( const Matrix2< T > & a,
const Matrix2< T > & b )
friend

◆ operator* [1/4]

template<typename T >
auto operator* ( const Matrix2< T > & a,
const Matrix2< T > & b ) -> Matrix2<decltype( dot( std::declval<Vector2<T>>(), std::declval<Vector2<T>>() ) )>
friend

product of two matrices

◆ operator* [2/4]

template<typename T >
auto operator* ( const Matrix2< T > & a,
const Vector2< T > & b ) -> Vector2<decltype( dot( std::declval<Vector2<T>>(), std::declval<Vector2<T>>() ) )>
friend

x = a * b

◆ operator* [3/4]

template<typename T >
auto operator* ( const Matrix2< T > & b,
T a ) -> Matrix2<decltype( std::declval<T>() * std::declval<T>() )>
friend

◆ operator* [4/4]

template<typename T >
auto operator* ( T a,
const Matrix2< T > & b ) -> Matrix2<decltype( std::declval<T>() * std::declval<T>() )>
friend

◆ operator*=

template<typename T >
Matrix2< T > & operator*= ( Matrix2< T > & a,
T b )
friend

◆ operator+

template<typename T >
auto operator+ ( const Matrix2< T > & a,
const Matrix2< T > & b ) -> Matrix2<decltype( std::declval<T>() + std::declval<T>() )>
friend

◆ operator+=

template<typename T >
Matrix2< T > & operator+= ( Matrix2< T > & a,
const Matrix2< T > & b )
friend

◆ operator-

template<typename T >
auto operator- ( const Matrix2< T > & a,
const Matrix2< T > & b ) -> Matrix2<decltype( std::declval<T>() - std::declval<T>() )>
friend

◆ operator-=

template<typename T >
Matrix2< T > & operator-= ( Matrix2< T > & a,
const Matrix2< T > & b )
friend

◆ operator/

template<typename T >
auto operator/ ( Matrix2< T > b,
T a ) -> Matrix2<decltype( std::declval<T>() / std::declval<T>() )>
friend

◆ operator/=

template<typename T >
Matrix2< T > & operator/= ( Matrix2< T > & a,
T b )
friend

◆ operator==

template<typename T >
bool operator== ( const Matrix2< T > & a,
const Matrix2< T > & b )
friend

◆ outer()

template<typename T >
Matrix2< T > outer ( const Vector2< T > & a,
const Vector2< T > & b )
related

x = a * b^T

Member Data Documentation

◆ x

template<typename T >
Vector2<T> MR::Matrix2< T >::x { 1, 0 }

rows, identity matrix by default

◆ y

template<typename T >
Vector2<T> MR::Matrix2< T >::y { 0, 1 }

The documentation for this struct was generated from the following file: