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

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
 

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 >())>
 NOTE: We use std::declval() in the operators below because libclang 18 in our binding generator is bugged and chokes on decltyping a.x and such. TODO fix this when we update libclang.
 
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
 
std::ostream & operator<< (std::ostream &s, const Matrix2 &mat)
 
std::istream & operator>> (std::istream &s, Matrix2 &mat)
 

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


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