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

#include <MRMatrix4.h>

Public Types

using ValueType = T
 
using VectorType = Vector4<T>
 

Public Member Functions

constexpr Matrix4 () noexcept=default
 
constexpr Matrix4 (const Vector4< T > &x, const Vector4< T > &y, const Vector4< T > &z, const Vector4< T > &w)
 initializes matrix from 4 row-vectors
 
constexpr Matrix4 (const Matrix3< T > &r, const Vector3< T > &t)
 construct from rotation matrix and translation vector
 
template<MR_SAME_TYPE_TEMPLATE_PARAM(T, TT) >
constexpr Matrix4 (const AffineXf3< TT > &xf)
 
template<typename U >
constexpr Matrix4 (const Matrix4< U > &m)
 
constexpr const T & operator() (int row, int col) const noexcept
 element access
 
constexpr T & operator() (int row, int col) noexcept
 
constexpr const Vector4< T > & operator[] (int row) const noexcept
 row access
 
constexpr Vector4< T > & operator[] (int row) noexcept
 
constexpr Vector4< 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
 
Matrix3< T > submatrix3 (int i, int j) const noexcept
 computes submatrix of the matrix with excluded i-th row and j-th column
 
det () const noexcept
 computes determinant of the matrix
 
constexpr Matrix4< T > inverse () const noexcept
 computes inverse matrix
 
constexpr Matrix4< T > transposed () const noexcept
 computes transposed matrix
 
constexpr Matrix3< T > getRotation () const noexcept
 
void setRotation (const Matrix3< T > &rot) noexcept
 
constexpr Vector3< T > getTranslation () const noexcept
 
void setTranslation (const Vector3< T > &t) noexcept
 
constexpr T * data ()
 
constexpr const T * data () const
 
template<MR_SAME_TYPE_TEMPLATE_PARAM(T, TT) >
 operator AffineXf3< TT > () const
 
Vector3< T > operator() (const Vector3< T > &b) const
 

Static Public Member Functions

static constexpr Matrix4 zero () noexcept
 
static constexpr Matrix4 identity () noexcept
 
static constexpr Matrix4 scale (T s) noexcept
 returns a matrix that scales uniformly
 

Public Attributes

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

Friends

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

Related Symbols

(Note that these are not member symbols.)

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

Detailed Description

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

arbitrary 4x4 matrix

Member Typedef Documentation

◆ ValueType

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

◆ VectorType

template<typename T >
using MR::Matrix4< T >::VectorType = Vector4<T>

Constructor & Destructor Documentation

◆ Matrix4() [1/5]

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

◆ Matrix4() [2/5]

template<typename T >
MR::Matrix4< T >::Matrix4 ( const Vector4< T > & x,
const Vector4< T > & y,
const Vector4< T > & z,
const Vector4< T > & w )
inlineconstexpr

initializes matrix from 4 row-vectors

◆ Matrix4() [3/5]

template<typename T >
MR::Matrix4< T >::Matrix4 ( const Matrix3< T > & r,
const Vector3< T > & t )
inlineconstexpr

construct from rotation matrix and translation vector

◆ Matrix4() [4/5]

template<typename T >
template<MR_SAME_TYPE_TEMPLATE_PARAM(T, TT) >
MR::Matrix4< T >::Matrix4 ( const AffineXf3< TT > & xf)
inlineconstexpr

◆ Matrix4() [5/5]

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

Member Function Documentation

◆ col()

template<typename T >
Vector4< T > MR::Matrix4< T >::col ( int i) const
inlineconstexprnoexcept

column access

◆ data() [1/2]

template<typename T >
T * MR::Matrix4< T >::data ( )
inlineconstexpr

◆ data() [2/2]

template<typename T >
const T * MR::Matrix4< T >::data ( ) const
inlineconstexpr

◆ det()

template<typename T >
T MR::Matrix4< T >::det ( ) const
noexcept

computes determinant of the matrix

◆ getRotation()

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

◆ getTranslation()

template<typename T >
Vector3< T > MR::Matrix4< T >::getTranslation ( ) const
constexprnoexcept

◆ identity()

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

◆ inverse()

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

computes inverse matrix

◆ norm()

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

◆ normSq()

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

compute sum of squared matrix elements

◆ operator AffineXf3< TT >()

template<typename T >
template<MR_SAME_TYPE_TEMPLATE_PARAM(T, TT) >
MR::Matrix4< T >::operator AffineXf3< TT > ( ) const
inline

◆ operator()() [1/3]

template<typename T >
Vector3< T > MR::Matrix4< T >::operator() ( const Vector3< T > & b) const

converts 3d-vector b in 4d-vector (b,1), multiplies matrix on it, and assuming the result is in homogeneous coordinates returns it as 3d-vector

◆ operator()() [2/3]

template<typename T >
const T & MR::Matrix4< T >::operator() ( int row,
int col ) const
inlineconstexprnoexcept

element access

◆ operator()() [3/3]

template<typename T >
T & MR::Matrix4< T >::operator() ( int row,
int col )
inlineconstexprnoexcept

◆ operator[]() [1/2]

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

row access

◆ operator[]() [2/2]

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

◆ scale()

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

returns a matrix that scales uniformly

◆ setRotation()

template<typename T >
void MR::Matrix4< T >::setRotation ( const Matrix3< T > & rot)
noexcept

◆ setTranslation()

template<typename T >
void MR::Matrix4< T >::setTranslation ( const Vector3< T > & t)
noexcept

◆ submatrix3()

template<typename T >
Matrix3< T > MR::Matrix4< T >::submatrix3 ( int i,
int j ) const
noexcept

computes submatrix of the matrix with excluded i-th row and j-th column

◆ trace()

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

computes trace of the matrix

◆ transposed()

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

computes transposed matrix

◆ zero()

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

Friends And Related Symbol Documentation

◆ dot()

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

double-dot product: x = a : b

◆ operator!=

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

◆ operator* [1/4]

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

product of two matrices

◆ operator* [2/4]

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

x = a * b

◆ operator* [3/4]

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

◆ operator* [4/4]

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

◆ operator*=

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

◆ operator+

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

◆ operator+=

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

◆ operator-

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

◆ operator-=

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

◆ operator/

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

◆ operator/=

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

◆ operator==

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

◆ outer()

template<typename T >
Matrix4< T > outer ( const Vector4< T > & a,
const Vector4< T > & b )
related

x = a * b^T

Member Data Documentation

◆ w

template<typename T >
Vector4<T> MR::Matrix4< T >::w { 0, 0, 0, 1 }

◆ x

template<typename T >
Vector4<T> MR::Matrix4< T >::x { 1, 0, 0, 0 }

rows, identity matrix by default

◆ y

template<typename T >
Vector4<T> MR::Matrix4< T >::y { 0, 1, 0, 0 }

◆ z

template<typename T >
Vector4<T> MR::Matrix4< T >::z { 0, 0, 1, 0 }

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