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

#include <MRMatrix3.h>

Classes

struct  QR
 returns 3 Euler angles, assuming this is a rotation matrix composed as follows: R=R(z)*R(y)*R(x) More...
 

Public Types

using ValueType = T
 
using VectorType = Vector3<T>
 

Public Member Functions

constexpr Matrix3 () noexcept=default
 
constexpr Matrix3 (const Vector3< T > &x, const Vector3< T > &y, const Vector3< T > &z)
 initializes matrix from its 3 rows
 
template<typename U >
constexpr Matrix3 (const Matrix3< U > &m)
 
constexpr const Vector3< T > & operator[] (int row) const noexcept
 row access
 
constexpr Vector3< T > & operator[] (int row) noexcept
 
constexpr Vector3< 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 Matrix3< T > inverse() const noexcept MR_REQUIRES_IF_SUPPORTED(!std constexpr Matrix3< T > transposed () const noexcept
 computes inverse matrix
 

Static Public Member Functions

static constexpr Matrix3 zero () noexcept
 
static constexpr Matrix3 identity () noexcept
 
static constexpr Matrix3 scale (T s) noexcept
 returns a matrix that scales uniformly
 
static constexpr Matrix3 scale (T sx, T sy, T sz) noexcept
 returns a matrix that has its own scale along each axis
 
static constexpr Matrix3 scale (const Vector3< T > &s) noexcept
 
static constexpr Matrix3 fromColumns (const Vector3< T > &x, const Vector3< T > &y, const Vector3< T > &z) noexcept
 

Public Attributes

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

Static Public Attributes

static constexpr Matrix3 static rotation(const Vector3< T > &axis, T angle) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static rotation(const Vector3< T > &from, const Vector3< T > &to) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static rotationFromEuler(const Vector3< T > &eulerAngles) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static approximateLinearRotationMatrixFromEuler(const Vector3< T > &eulerAngles) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix fromRows )(const Vector3< T > &x, const Vector3< T > &y, const Vector3< T > &z) noexcept
 creates matrix representing rotation around given axis on given angle
 

Friends

QR qr() const noexcept MR_REQUIRES_IF_SUPPORTED(!std friend constexpr bool operator== (const Matrix3< T > &a, const Matrix3< T > &b)
 decompose this matrix on the product Q*R, where Q is orthogonal and R is upper triangular
 
constexpr bool operator!= (const Matrix3< T > &a, const Matrix3< T > &b)
 
constexpr auto operator+ (const Matrix3< T > &a, const Matrix3< T > &b) -> Matrix3< decltype(std::declval< T >()+std::declval< T >())>
 
constexpr auto operator- (const Matrix3< T > &a, const Matrix3< T > &b) -> Matrix3< decltype(std::declval< T >() - std::declval< T >())>
 
constexpr auto operator* (T a, const Matrix3< T > &b) -> Matrix3< decltype(std::declval< T >() *std::declval< T >())>
 
constexpr auto operator* (const Matrix3< T > &b, T a) -> Matrix3< decltype(std::declval< T >() *std::declval< T >())>
 
constexpr auto operator/ (Matrix3< T > b, T a) -> Matrix3< decltype(std::declval< T >()/std::declval< T >())>
 
constexpr Matrix3< T > & operator+= (Matrix3< T > &a, const Matrix3< T > &b)
 
constexpr Matrix3< T > & operator-= (Matrix3< T > &a, const Matrix3< T > &b)
 
constexpr Matrix3< T > & operator*= (Matrix3< T > &a, T b)
 
constexpr Matrix3< T > & operator/= (Matrix3< T > &a, T b)
 
constexpr auto operator* (const Matrix3< T > &a, const Vector3< T > &b) -> Vector3< decltype(dot(std::declval< Vector3< T > >(), std::declval< Vector3< T > >()))>
 x = a * b
 
constexpr auto operator* (const Matrix3< T > &a, const Matrix3< T > &b) -> Matrix3< decltype(dot(std::declval< Vector3< T > >(), std::declval< Vector3< T > >()))>
 product of two matrices
 

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

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

arbitrary 3x3 matrix

Member Typedef Documentation

◆ ValueType

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

◆ VectorType

template<typename T >
using MR::Matrix3< T >::VectorType = Vector3<T>

Constructor & Destructor Documentation

◆ Matrix3() [1/3]

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

◆ Matrix3() [2/3]

template<typename T >
MR::Matrix3< T >::Matrix3 ( const Vector3< T > & x,
const Vector3< T > & y,
const Vector3< T > & z )
inlineconstexpr

initializes matrix from its 3 rows

◆ Matrix3() [3/3]

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

Member Function Documentation

◆ col()

template<typename T >
Vector3< T > MR::Matrix3< T >::col ( int i) const
inlineconstexprnoexcept

column access

◆ det()

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

computes determinant of the matrix

◆ fromColumns()

template<typename T >
static constexpr Matrix3 MR::Matrix3< T >::fromColumns ( const Vector3< T > & x,
const Vector3< T > & y,
const Vector3< T > & z )
inlinestaticconstexprnoexcept

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

◆ identity()

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

◆ norm()

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

◆ normSq()

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

compute sum of squared matrix elements

◆ operator[]() [1/2]

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

row access

◆ operator[]() [2/2]

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

◆ scale() [1/3]

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

◆ scale() [2/3]

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

returns a matrix that scales uniformly

◆ scale() [3/3]

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

returns a matrix that has its own scale along each axis

◆ trace()

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

computes trace of the matrix

◆ transposed()

template<typename T >
Matrix3< T > inverse() const noexcept MR_REQUIRES_IF_SUPPORTED(!std constexpr Matrix3< T > MR::Matrix3< T >::transposed ( ) const
constexprnoexcept

computes inverse matrix

computes transposed matrix

◆ zero()

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

Friends And Related Symbol Documentation

◆ dot()

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

double-dot product: x = a : b

◆ operator!=

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

◆ operator* [1/4]

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

product of two matrices

◆ operator* [2/4]

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

x = a * b

◆ operator* [3/4]

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

◆ operator* [4/4]

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

◆ operator*=

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

◆ operator+

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

◆ operator+=

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

◆ operator-

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

◆ operator-=

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

◆ operator/

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

◆ operator/=

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

◆ operator==

template<typename T >
QR qr() const noexcept MR_REQUIRES_IF_SUPPORTED(!std friend constexpr bool operator== ( const Matrix3< T > & a,
const Matrix3< T > & b )
friend

decompose this matrix on the product Q*R, where Q is orthogonal and R is upper triangular

◆ outer()

template<typename T >
Matrix3< T > outer ( const Vector3< T > & a,
const Vector3< T > & b )
related

x = a * b^T

Member Data Documentation

◆ fromRows

template<typename T >
Matrix3 static rotation(const Vector3< T > &axis, T angle) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static rotation(const Vector3< T > &from, const Vector3< T > &to) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static rotationFromEuler(const Vector3< T > &eulerAngles) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix3 static approximateLinearRotationMatrixFromEuler(const Vector3< T > &eulerAngles) noexcept MR_REQUIRES_IF_SUPPORTED(std constexpr Matrix MR::Matrix3< T >::fromRows) (const Vector3< T > &x, const Vector3< T > &y, const Vector3< T > &z) noexcept
inlinestaticconstexprnoexcept

creates matrix representing rotation around given axis on given angle

creates matrix representing rotation that after application to (from) makes (to) vector creates matrix representing rotation from 3 Euler angles: R=R(z)*R(y)*R(x) see more https://en.wikipedia.org/wiki/Euler_angles#Conventions_by_intrinsic_rotations returns linear by angles approximation of the rotation matrix, which is close to true rotation matrix for small angles constructs a matrix from its 3 rows

◆ x

template<typename T >
Vector3<T> MR::Matrix3< T >::x { 1, 0, 0 }

rows, identity matrix by default

◆ y

template<typename T >
Vector3<T> MR::Matrix3< T >::y { 0, 1, 0 }

◆ z

template<typename T >
Vector3<T> MR::Matrix3< T >::z { 0, 0, 1 }

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