Atoms Crowd  7.0.0
Matrix44< T > Class Template Reference

#include <ImathMatrix.h>

Public Types

typedef T BaseType
 The base type: In templates that accept a parameter V (could be a Color4), you can refer to T as V::BaseType
 
typedef Vec4< T > BaseVecType
 The base vector type.
 

Public Member Functions

ATOMSMATH_HOSTDEVICE T * operator[] (int i) noexcept
 Row access.
 
ATOMSMATH_HOSTDEVICE const T * operator[] (int i) const noexcept
 Row access.
 
template<class S >
ATOMSMATH_CONSTEXPR14 Matrix44 (const Matrix44< S > &v) noexcept
 
template<class S >
void getValue (Matrix44< S > &v) const noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 Matrix44< T > & setValue (const Matrix44< S > &v) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 Matrix44< T > & setTheMatrix (const Matrix44< S > &v) noexcept
 
template<class S >
void multVecMatrix (const Vec3< S > &src, Vec3< S > &dst) const noexcept
 
template<class S >
void multDirMatrix (const Vec3< S > &src, Vec3< S > &dst) const noexcept
 
template<class S >
const Matrix44< T > & setEulerAngles (const Vec3< S > &r) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & setAxisAngle (const Vec3< S > &axis, S angle) noexcept
 
template<class S >
const Matrix44< T > & rotate (const Vec3< S > &r) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & setScale (const Vec3< S > &s) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & scale (const Vec3< S > &s) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & setTranslation (const Vec3< S > &t) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & translate (const Vec3< S > &t) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & setShear (const Vec3< S > &h) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & setShear (const Shear6< S > &h) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & shear (const Vec3< S > &h) noexcept
 
template<class S >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & shear (const Shear6< S > &h) noexcept
 
Constructors and Assignment
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 () noexcept
 Uninitialized. More...
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (T a) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (const T a[4][4]) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (T a, T b, T c, T d, T e, T f, T g, T h, T i, T j, T k, T l, T m, T n, T o, T p) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (Matrix33< T > r, Vec3< T > t) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (const Matrix44 &v) noexcept
 Copy constructor.
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 (const Matrix44< S > &v) noexcept
 Construct from Matrix44 of another base type.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator= (const Matrix44 &v) noexcept
 Assignment operator.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator= (T a) noexcept
 Assignment from scalar.
 
 ~Matrix44 () noexcept=default
 Destructor.
 
Compatibility with Sb
ATOMSMATH_HOSTDEVICE T * getValue () noexcept
 Return a raw pointer to the array of values.
 
ATOMSMATH_HOSTDEVICE const T * getValue () const noexcept
 Return a raw pointer to the array of values.
 
template<class S >
ATOMSMATH_HOSTDEVICE void getValue (Matrix44< S > &v) const noexcept
 Return the value in v
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44setValue (const Matrix44< S > &v) noexcept
 Set the value.
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44setTheMatrix (const Matrix44< S > &v) noexcept
 Set the value.
 
Maniplation
ATOMSMATH_HOSTDEVICE void makeIdentity () noexcept
 Set to the identity matrix.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44transpose () noexcept
 Transpose.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 transposed () const noexcept
 Return the transpose.
 
ATOMSMATH_CONSTEXPR14 const Matrix44invert (bool singExc)
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44invert () noexcept
 
ATOMSMATH_CONSTEXPR14 Matrix44< T > inverse (bool singExc) const
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44< T > inverse () const noexcept
 Return the inverse using the determinant, leaving this unmodified.
 
ATOMSMATH_CONSTEXPR14 const Matrix44gjInvert (bool singExc)
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44gjInvert () noexcept
 
Matrix44< T > gjInverse (bool singExc) const
 
ATOMSMATH_HOSTDEVICE Matrix44< T > gjInverse () const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T minorOf (const int r, const int c) const noexcept
 Calculate the matrix minor of the (r,c) element.
 
constexpr ATOMSMATH_HOSTDEVICE T fastMinor (const int r0, const int r1, const int r2, const int c0, const int c1, const int c2) const noexcept
 Build a minor using the specified rows and columns.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 T determinant () const noexcept
 Determinant.
 
template<class S >
ATOMSMATH_HOSTDEVICE const Matrix44setEulerAngles (const Vec3< S > &r) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setAxisAngle (const Vec3< S > &ax, S ang) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE const Matrix44rotate (const Vec3< S > &r) noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setScale (T s) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setScale (const Vec3< S > &s) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44scale (const Vec3< S > &s) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setTranslation (const Vec3< S > &t) noexcept
 
constexpr ATOMSMATH_HOSTDEVICE const Vec3< T > translation () const noexcept
 Return translation component.
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44translate (const Vec3< S > &t) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setShear (const Vec3< S > &h) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44setShear (const Shear6< S > &h) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44shear (const Vec3< S > &h) noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44shear (const Shear6< S > &h) noexcept
 

Static Public Member Functions

constexpr static ATOMSMATH_HOSTDEVICE unsigned int dimensions () noexcept
 Return the number of the row and column dimensions, i.e. 4.
 
Numeric Limits
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeLowest () noexcept
 Largest possible negative value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeMax () noexcept
 Largest possible positive value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeSmallest () noexcept
 Smallest possible positive value.
 
constexpr static ATOMSMATH_HOSTDEVICE T baseTypeEpsilon () noexcept
 Smallest possible e for which 1+e != 1.
 

Public Attributes

Direct access to elements
x [4][4]
 Matrix elements.
 

Arithmetic and Comparison

constexpr ATOMSMATH_HOSTDEVICE bool operator== (const Matrix44 &v) const noexcept
 Equality.
 
constexpr ATOMSMATH_HOSTDEVICE bool operator!= (const Matrix44 &v) const noexcept
 Inequality.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithAbsError (const Matrix44< T > &v, T e) const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 bool equalWithRelError (const Matrix44< T > &v, T e) const noexcept
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator+= (const Matrix44 &v) noexcept
 Component-wise addition.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator+= (T a) noexcept
 Component-wise addition.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator+ (const Matrix44 &v) const noexcept
 Component-wise addition.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator-= (const Matrix44 &v) noexcept
 Component-wise subtraction.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator-= (T a) noexcept
 Component-wise subtraction.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator- (const Matrix44 &v) const noexcept
 Component-wise subtraction.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator- () const noexcept
 Component-wise multiplication by -1.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44negate () noexcept
 Component-wise multiplication by -1.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator*= (T a) noexcept
 Component-wise multiplication.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator* (T a) const noexcept
 Component-wise multiplication.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator/= (T a) noexcept
 Component-wise division.
 
constexpr ATOMSMATH_HOSTDEVICE Matrix44 operator/ (T a) const noexcept
 Component-wise division.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44operator*= (const Matrix44 &v) noexcept
 Matrix-matrix multiplication.
 
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 Matrix44 operator* (const Matrix44 &v) const noexcept
 Matrix-matrix multiplication.
 
template<class S >
ATOMSMATH_HOSTDEVICE void multVecMatrix (const Vec3< S > &src, Vec3< S > &dst) const noexcept
 
template<class S >
ATOMSMATH_HOSTDEVICE void multDirMatrix (const Vec3< S > &src, Vec3< S > &dst) const noexcept
 
static ATOMSMATH_HOSTDEVICE void multiply (const Matrix44 &a, const Matrix44 &b, Matrix44 &c) noexcept
 Matrix-matrix multiplication: compute c = a * b.
 

Detailed Description

template<class T>
class Matrix44< T >

4x4 transformation matrix

Constructor & Destructor Documentation

◆ Matrix44() [1/5]

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T >::Matrix44
inlinenoexcept

Uninitialized.

Default constructor: initialize to identity 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0 1

◆ Matrix44() [2/5]

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T >::Matrix44 ( a)
inlinenoexcept

Initialize to scalar constant a a a a a a a a a a a a a a a a

◆ Matrix44() [3/5]

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T >::Matrix44 ( const T  a[4][4])
inlinenoexcept

Construct from 4x4 array a[0][0] a[0][1] a[0][2] a[0][3] a[1][0] a[1][1] a[1][2] a[1][3] a[2][0] a[2][1] a[2][2] a[2][3] a[3][0] a[3][1] a[3][2] a[3][3]

◆ Matrix44() [4/5]

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T >::Matrix44 ( a,
b,
c,
d,
e,
f,
g,
h,
i,
j,
k,
l,
m,
n,
o,
p 
)
inlinenoexcept

Construct from given scalar values a b c d e f g h i j k l m n o p

◆ Matrix44() [5/5]

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T >::Matrix44 ( Matrix33< T >  r,
Vec3< T >  t 
)
inlinenoexcept

Construct from a 3x3 rotation matrix and a translation vector r r r 0 r r r 0 r r r 0 t t t 1

Member Function Documentation

◆ equalWithAbsError()

template<class T >
ATOMSMATH_CONSTEXPR14 bool Matrix44< T >::equalWithAbsError ( const Matrix44< T > &  v,
e 
) const
inlinenoexcept

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with an absolute error of no more than e, i.e., for all i, j:

abs (this[i][j] - m[i][j]) <= e

◆ equalWithRelError()

template<class T >
ATOMSMATH_CONSTEXPR14 bool Matrix44< T >::equalWithRelError ( const Matrix44< T > &  v,
e 
) const
inlinenoexcept

Compare two matrices and test if they are "approximately equal":

Returns
True if the coefficients of this and m are the same with a relative error of no more than e, i.e., for all i, j:

abs (this[i] - v[i][j]) <= e * abs (this[i][j])

◆ gjInverse() [1/2]

template<class T >
Matrix44< T > Matrix44< T >::gjInverse
inlinenoexcept

Return the inverse using the Gauss-Jordan method, leaving this unmodified Significantly slower but more accurate than inverse().

◆ gjInverse() [2/2]

template<class T >
Matrix44< T > Matrix44< T >::gjInverse ( bool  singExc) const
inline

Return the inverse using the Gauss-Jordan method, leaving this unmodified. Significantly slower but more accurate than inverse().

◆ gjInvert() [1/2]

template<class T >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & Matrix44< T >::gjInvert
inlinenoexcept

Invert in place using the Gauss-Jordan method. Significantly slower but more accurate than invert().

Returns
const reference to this

◆ gjInvert() [2/2]

template<class T >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & Matrix44< T >::gjInvert ( bool  singExc)
inline

Invert in place using the Gauss-Jordan method. Significantly slower but more accurate than invert().

Parameters
singExcIf true, throw an exception if the matrix cannot be inverted.
Returns
const reference to this

◆ inverse()

template<class T >
ATOMSMATH_CONSTEXPR14 Matrix44< T > Matrix44< T >::inverse ( bool  singExc) const
inline

Return the inverse using the determinant, leaving this unmodified.

Parameters
singExcIf true, throw an exception if the matrix cannot be inverted.

◆ invert() [1/2]

template<class T >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & Matrix44< T >::invert
inlinenoexcept

Invert in place using the determinant.

Returns
const reference to this

◆ invert() [2/2]

template<class T >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & Matrix44< T >::invert ( bool  singExc)
inline

Invert in place using the determinant.

Parameters
singExcIf true, throw an exception if the matrix cannot be inverted.
Returns
const reference to this

◆ multDirMatrix()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE void Matrix44< T >::multDirMatrix ( const Vec3< S > &  src,
Vec3< S > &  dst 
) const
noexcept

Vector-matrix multiplication: multiply src by the upper left 2x2 submatrix, ignoring the rest of matrix.

Parameters
[in]srcThe input vector
[out]dstThe output vector

◆ multVecMatrix()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE void Matrix44< T >::multVecMatrix ( const Vec3< S > &  src,
Vec3< S > &  dst 
) const
noexcept

Vector-matrix multiplication: a homogeneous transformation by computing Vec3 (src.x, src.y, src.z, 1) * m and dividing by the result's third element.

Parameters
[in]srcThe input vector
[out]dstThe output vector

◆ rotate()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE const Matrix44& Matrix44< T >::rotate ( const Vec3< S > &  r)
noexcept

Rotate the matrix by XYZ euler angles in r (in radians)

Returns
const referenced to this

◆ scale()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::scale ( const Vec3< S > &  s)
noexcept

Scale the matrix by s

Returns
const referenced to this

◆ setAxisAngle()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::setAxisAngle ( const Vec3< S > &  ax,
ang 
)
noexcept

Set matrix to rotation around given axis by given angle (in radians)

Returns
const referenced to this

◆ setEulerAngles()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE const Matrix44& Matrix44< T >::setEulerAngles ( const Vec3< S > &  r)
noexcept

Set matrix to rotation by XYZ euler angles (in radians)

Returns
const referenced to this

◆ setScale() [1/2]

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::setScale ( const Vec3< S > &  s)
noexcept

Set matrix to scale by given vector

Returns
const referenced to this

◆ setScale() [2/2]

template<class T >
ATOMSMATH_CONSTEXPR14 const Matrix44< T > & Matrix44< T >::setScale ( s)
inlinenoexcept

Set matrix to scale by given uniform factor

Returns
const referenced to this

◆ setShear() [1/2]

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::setShear ( const Shear6< S > &  h)
noexcept

Set matrix to shear by given factors. The resulting matrix

  • will shear x for each y coord. by a factor of h.xy ;
  • will shear x for each z coord. by a factor of h.xz ;
  • will shear y for each z coord. by a factor of h.yz ;
  • will shear y for each x coord. by a factor of h.yx ;
  • will shear z for each x coord. by a factor of h.zx ;
  • will shear z for each y coord. by a factor of h.zy .
    Returns
    const referenced to this

◆ setShear() [2/2]

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::setShear ( const Vec3< S > &  h)
noexcept

Set matrix to shear by given vector h. The resulting matrix

  • will shear x for each y coord. by a factor of h[0] ;
  • will shear x for each z coord. by a factor of h[1] ;
  • will shear y for each z coord. by a factor of h[2] .
    Returns
    const referenced to this

◆ setTranslation()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::setTranslation ( const Vec3< S > &  t)
noexcept

Set matrix to translation by given vector

Returns
const referenced to this

◆ shear() [1/2]

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::shear ( const Shear6< S > &  h)
noexcept

Shear the matrix by the given factors. The composed matrix will be shear * this, where the shear matrix ...

  • will shear x for each y coord. by a factor of h.xy ;
  • will shear x for each z coord. by a factor of h.xz ;
  • will shear y for each z coord. by a factor of h.yz ;
  • will shear y for each x coord. by a factor of h.yx ;
  • will shear z for each x coord. by a factor of h.zx ;
  • will shear z for each y coord. by a factor of h.zy .
    Returns
    const referenced to this

◆ shear() [2/2]

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::shear ( const Vec3< S > &  h)
noexcept

Shear the matrix by given vector. The composed matrix will be shear * this, where the shear matrix ...

  • will shear x for each y coord. by a factor of h[0] ;
  • will shear x for each z coord. by a factor of h[1] ;
  • will shear y for each z coord. by a factor of h[2] .
    Returns
    const referenced to this

◆ translate()

template<class T >
template<class S >
ATOMSMATH_HOSTDEVICE ATOMSMATH_CONSTEXPR14 const Matrix44& Matrix44< T >::translate ( const Vec3< S > &  t)
noexcept

Translate the matrix by t

Returns
const referenced to this

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