MeshLib
 
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 MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2< T > transposed () const noexcept
 computes inverse matrix
 
Matrix2operator+= (const Matrix2< T > &b)
 
Matrix2operator-= (const Matrix2< T > &b)
 
Matrix2operator*= (T b)
 
Matrix2operator/= (T b)
 

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 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 }
 

Static Public Attributes

static constexpr Matrix2 static rotation(T angle) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2 static rotation(const Vector2< T > &from, const Vector2< T > &to) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix fromRows )(const Vector2< T > &x, const Vector2< T > &y) noexcept
 creates matrix representing rotation around origin on given angle
 

Related Symbols

(Note that these are not member symbols.)

template<typename T >
Vector2< T > operator* (const Matrix2< T > &a, const Vector2< T > &b)
 x = a * b
 
template<typename T >
dot (const Matrix2< T > &a, const Matrix2< T > &b)
 double-dot product: x = a : b
 
template<typename T >
Matrix2< T > operator* (const Matrix2< T > &a, const Matrix2< T > &b)
 product of two matrices
 
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

◆ identity()

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

◆ 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*=()

template<typename T >
Matrix2 & MR::Matrix2< T >::operator*= ( T b)
inline

◆ operator+=()

template<typename T >
Matrix2 & MR::Matrix2< T >::operator+= ( const Matrix2< T > & b)
inline

◆ operator-=()

template<typename T >
Matrix2 & MR::Matrix2< T >::operator-= ( const Matrix2< T > & b)
inline

◆ operator/=()

template<typename T >
Matrix2 & MR::Matrix2< T >::operator/= ( T b)
inline

◆ 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

◆ 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 > inverse() const noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2< T > MR::Matrix2< T >::transposed ( ) const
constexprnoexcept

computes inverse matrix

computes transposed matrix

◆ zero()

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

Friends And Related Symbol Documentation

◆ dot()

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

double-dot product: x = a : b

◆ operator*() [1/2]

template<typename T >
Matrix2< T > operator* ( const Matrix2< T > & a,
const Matrix2< T > & b )
related

product of two matrices

◆ operator*() [2/2]

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

x = a * b

◆ outer()

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

x = a * b^T

Member Data Documentation

◆ fromRows

template<typename T >
Matrix2 static rotation(T angle) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix2 static rotation(const Vector2< T > &from, const Vector2< T > &to) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix MR::Matrix2< T >::fromRows) (const Vector2< T > &x, const Vector2< T > &y) noexcept
inlinestaticconstexprnoexcept

creates matrix representing rotation around origin on given angle

creates matrix representing rotation that after application to (from) makes (to) vector constructs a matrix from its 2 rows

◆ 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: