Loading...
Searching...
No Matches
Mat4< T > Class Template Reference

4x4 -matrix class. More...

`#include <openvdb/math/Mat4.h>`

Inheritance diagram for Mat4< T >:

## Public Types

using | value_type = T
| Data type held by the matrix.
using | ValueType = T
using | MyBase = Mat<4, T>
enum | SIZE_

## Public Member Functions

| Mat4 ()=default
template<typename Source>
| Mat4 (Source *a)
| Constructor given array of elements, the ordering is in row major form:
template<typename Source>
| Mat4 (Source a, Source b, Source c, Source d, Source e, Source f, Source g, Source h, Source i, Source j, Source k, Source l, Source m, Source n, Source o, Source p)
| Constructor given array of elements, the ordering is in row major form:
template<typename Source>
| Mat4 (const Vec4< Source > &v1, const Vec4< Source > &v2, const Vec4< Source > &v3, const Vec4< Source > &v4, bool rows=true)
template<typename Source>
| Mat4 (const Mat4< Source > &m)
| Conversion constructor.
void | setRow (int i, const Vec4< T > &v)
| Set ith row to vector v.
Vec4< T > | row (int i) const
| Get ith row, e.g. Vec4f v = m.row(1);.
void | setCol (int j, const Vec4< T > &v)
| Set jth column to vector v.
Vec4< T > | col (int j) const
| Get jth column, e.g. Vec4f v = m.col(0);.
T & | operator() (int i, int j)
T | operator() (int i, int j) const
void | setRows (const Vec4< T > &v1, const Vec4< T > &v2, const Vec4< T > &v3, const Vec4< T > &v4)
| Set the rows of this matrix to the vectors v1, v2, v3, v4.
void | setColumns (const Vec4< T > &v1, const Vec4< T > &v2, const Vec4< T > &v3, const Vec4< T > &v4)
| Set the columns of this matrix to the vectors v1, v2, v3, v4.
void | setZero ()
void | setIdentity ()
| Set this matrix to identity.
void | setMat3 (const Mat3< T > &m)
| Set upper left to a Mat3.
Mat3< T > | getMat3 () const
Vec3< T > | getTranslation () const
| Return the translation component.
void | setTranslation (const Vec3< T > &t)
template<typename Source>
const Mat4 & | operator= (const Mat4< Source > &m)
| Assignment operator.
bool | eq (const Mat4 &m, T eps=1.0e-8) const
| Return `true` if this matrix is equivalent to m within a tolerance of eps.
Mat4< T > | operator- () const
| Negation operator, for e.g. m1 = -m2;.
template<typename S>
const Mat4< T > & | operator*= (S scalar)
| Multiply each element of this matrix by scalar.
template<typename S>
const Mat4< T > & | operator+= (const Mat4< S > &m1)
| Add each element of the given matrix to the corresponding element of this matrix.
template<typename S>
const Mat4< T > & | operator-= (const Mat4< S > &m1)
| Subtract each element of the given matrix from the corresponding element of this matrix.
template<typename S>
const Mat4< T > & | operator*= (const Mat4< S > &m1)
| Multiply this matrix by the given matrix.
Mat4 | transpose () const
Mat4 | inverse (T tolerance=0) const
T | det () const
| Determinant of matrix.
template<typename T0>
void | setToTranslation (const Vec3< T0 > &v)
| Sets the matrix to a matrix that translates by v.
template<typename T0>
void | preTranslate (const Vec3< T0 > &tr)
| Left multiples by the specified translation, i.e. Trans * (*this).
template<typename T0>
void | postTranslate (const Vec3< T0 > &tr)
| Right multiplies by the specified translation matrix, i.e. (*this) * Trans.
template<typename T0>
void | setToScale (const Vec3< T0 > &v)
| Sets the matrix to a matrix that scales by v.
template<typename T0>
void | preScale (const Vec3< T0 > &v)
template<typename T0>
void | postScale (const Vec3< T0 > &v)
void | setToRotation (Axis axis, T angle)
| Sets the matrix to a rotation about the given axis.
void | setToRotation (const Vec3< T > &axis, T angle)
| Sets the matrix to a rotation about an arbitrary axis.
void | setToRotation (const Vec3< T > &v1, const Vec3< T > &v2)
| Sets the matrix to a rotation that maps v1 onto v2 about the cross product of v1 and v2.
void | preRotate (Axis axis, T angle)
| Left multiplies by a rotation clock-wiseabout the given axis into this matrix.
void | postRotate (Axis axis, T angle)
| Right multiplies by a rotation clock-wiseabout the given axis into this matrix.
void | setToShear (Axis axis0, Axis axis1, T shearby)
| Sets the matrix to a shear along axis0 by a fraction of axis1.
void | preShear (Axis axis0, Axis axis1, T shear)
| Left multiplies a shearing transformation into the matrix.
void | postShear (Axis axis0, Axis axis1, T shear)
| Right multiplies a shearing transformation into the matrix.
template<typename T0>
Vec4< T0 > | transform (const Vec4< T0 > &v) const
| Transform a Vec4 by post-multiplication.
template<typename T0>
Vec3< T0 > | transform (const Vec3< T0 > &v) const
| Transform a Vec3 by post-multiplication, without homogenous division.
template<typename T0>
Vec4< T0 > | pretransform (const Vec4< T0 > &v) const
| Transform a Vec4 by pre-multiplication.
template<typename T0>
Vec3< T0 > | pretransform (const Vec3< T0 > &v) const
| Transform a Vec3 by pre-multiplication, without homogenous division.
template<typename T0>
Vec3< T0 > | transformH (const Vec3< T0 > &p) const
| Transform a Vec3 by post-multiplication, doing homogenous divison.
template<typename T0>
Vec3< T0 > | pretransformH (const Vec3< T0 > &p) const
| Transform a Vec3 by pre-multiplication, doing homogenous division.
template<typename T0>
Vec3< T0 > | transform3x3 (const Vec3< T0 > &v) const
| Transform a Vec3 by post-multiplication, without translation.
std::string | str (unsigned indentation=0) const
T * | asPointer ()
| Direct access to the internal data.
const T * | asPointer () const
T * | operator[] (int i)
| Array style reference to ith row.
const T * | operator[] (int i) const
void | write (std::ostream &os) const
void | read (std::istream &is)
T | absMax () const
| Return the maximum of the absolute of all elements in this matrix.
bool | isNan () const
| True if a Nan is present in this matrix.
bool | isInfinite () const
| True if an Inf is present in this matrix.
bool | isFinite () const
| True if no Nan or Inf values are present.
bool | isZero () const
| True if all elements are exactly zero.

## Static Public Member Functions

static const Mat4< T > & | identity ()
| Predefined constant for identity matrix.
static const Mat4< T > & | zero ()
| Predefined constant for zero matrix.
static Mat4 | translation (const Vec3d &v)
| Sets the matrix to a matrix that translates by v.
static unsigned | numRows ()
static unsigned | numColumns ()
static unsigned | numElements ()

## Protected Attributes

T | mm [SIZE *SIZE]

## Related Symbols

(Note that these are not member symbols.)
template<typename T0, typename T1>
bool | operator== (const Mat4< T0 > &m0, const Mat4< T1 > &m1)
| Equality operator, does exact floating point comparisons.
template<typename T0, typename T1>
bool | operator!= (const Mat4< T0 > &m0, const Mat4< T1 > &m1)
| Inequality operator, does exact floating point comparisons.
template<typename S, typename T>
Mat4< typename promote< S, T >::type > | operator* (S scalar, const Mat4< T > &m)
| Multiply each element of the given matrix by scalar and return the result.
template<typename S, typename T>
Mat4< typename promote< S, T >::type > | operator* (const Mat4< T > &m, S scalar)
| Multiply each element of the given matrix by scalar and return the result.
template<typename T, typename MT>
Vec4< typename promote< T, MT >::type > | operator* (const Mat4< MT > &_m, const Vec4< T > &_v)
| Multiply _m by _v and return the resulting vector.
template<typename T, typename MT>
Vec4< typename promote< T, MT >::type > | operator* (const Vec4< T > &_v, const Mat4< MT > &_m)
| Multiply _v by _m and return the resulting vector.
template<typename T, typename MT>
Vec3< typename promote< T, MT >::type > | operator* (const Mat4< MT > &_m, const Vec3< T > &_v)
| Multiply _m by _v and return the resulting vector.
template<typename T, typename MT>
Vec3< typename promote< T, MT >::type > | operator* (const Vec3< T > &_v, const Mat4< MT > &_m)
| Multiply _v by _m and return the resulting vector.
template<typename T0, typename T1>
Mat4< typename promote< T0, T1 >::type > | operator+ (const Mat4< T0 > &m0, const Mat4< T1 > &m1)
| Add corresponding elements of m0 and m1 and return the result.
template<typename T0, typename T1>
Mat4< typename promote< T0, T1 >::type > | operator- (const Mat4< T0 > &m0, const Mat4< T1 > &m1)
| Subtract corresponding elements of m0 and m1 and return the result.
template<typename T0, typename T1>
Mat4< typename promote< T0, T1 >::type > | operator* (const Mat4< T0 > &m0, const Mat4< T1 > &m1)
| Multiply m0 by m1 and return the resulting matrix.

## Detailed Description

template<typename T>
class openvdb::v10_0::math::Mat4< T >

4x4 -matrix class.

## Member Typedef Documentation

## MyBase

template<typename T>

using MyBase = Mat<4, T>

## value_type

template<typename T>

using value_type = T

Data type held by the matrix.

## ValueType

template<typename T>

using ValueType = T

## Member Enumeration Documentation

## SIZE_

enum SIZE_

inherited

## Constructor & Destructor Documentation

## Mat4() [1/5]

template<typename T>

Mat4 | ( |  | ) |

default

Trivial constructor, the matrix is NOT initialized

Note
  destructor, copy constructor, assignment operator and move constructor are left to be defined by the compiler (default)

## Mat4() [2/5]

template<typename T>
template<typename Source>

Mat4 | ( | Source * | a | ) |

inline

Constructor given array of elements, the ordering is in row major form:

    a[ 0] a[1]  a[ 2] a[ 3]
    a[ 4] a[5]  a[ 6] a[ 7]
    a[ 8] a[9]  a[10] a[11]
    a[12] a[13] a[14] a[15]

## Mat4() [3/5]

template<typename T>
template<typename Source>

Mat4 | ( | Source | a,
|  | Source | b,
|  | Source | c,
|  | Source | d,
|  | Source | e,
|  | Source | f,
|  | Source | g,
|  | Source | h,
|  | Source | i,
|  | Source | j,
|  | Source | k,
|  | Source | l,
|  | Source | m,
|  | Source | n,
|  | Source | o,
|  | Source | p )

inline

Constructor given array of elements, the ordering is in row major form:

    a b c d
    e f g h
    i j k l
    m n o p

## Mat4() [4/5]

template<typename T>
template<typename Source>

Mat4 | ( | const Vec4< Source > & | v1,
|  | const Vec4< Source > & | v2,
|  | const Vec4< Source > & | v3,
|  | const Vec4< Source > & | v4,
|  | bool | rows = true )

inline

Construct matrix from rows or columns vectors (defaults to rows for historical reasons)

## Mat4() [5/5]

template<typename T>
template<typename Source>

Mat4 | ( | const Mat4< Source > & | m | ) |

inline explicit

Conversion constructor.

## Member Function Documentation

## absMax()

T absMax | ( |  | ) | const

inline inherited

Return the maximum of the absolute of all elements in this matrix.

## asPointer() [1/2]

T * asPointer | ( |  | ) |

inline inherited

Direct access to the internal data.

## asPointer() [2/2]

const T * asPointer | ( |  | ) | const

inline inherited

## col()

template<typename T>

Vec4< T > col | ( | int | j | ) | const

inline

Get jth column, e.g. Vec4f v = m.col(0);.

## det()

template<typename T>

T det | ( |  | ) | const

inline

Determinant of matrix.

## eq()

template<typename T>

bool eq | ( | const Mat4< T > & | m,
|  | T | eps = 1.0e-8 ) const

inline

Return `true` if this matrix is equivalent to m within a tolerance of eps.

## getMat3()

template<typename T>

Mat3< T > getMat3 | ( |  | ) | const

inline

## getTranslation()

template<typename T>

Vec3< T > getTranslation | ( |  | ) | const

inline

Return the translation component.

## identity()

template<typename T>

const Mat4< T > & identity | ( |  | ) |

inline static

Predefined constant for identity matrix.

## inverse()

template<typename T>

Mat4 inverse | ( | T | tolerance = 0 | ) | const

inline

Returns
  inverse of this

Exceptions

  ArithmeticError | if singular

## isFinite()

bool isFinite | ( |  | ) | const

inline inherited

True if no Nan or Inf values are present.

## isInfinite()

bool isInfinite | ( |  | ) | const

inline inherited

True if an Inf is present in this matrix.

## isNan()

bool isNan | ( |  | ) | const

inline inherited

True if a Nan is present in this matrix.

## isZero()

bool isZero | ( |  | ) | const

inline inherited

True if all elements are exactly zero.

## numColumns()

unsigned numColumns | ( |  | ) |

inline static inherited

## numElements()

unsigned numElements | ( |  | ) |

inline static inherited

## numRows()

unsigned numRows | ( |  | ) |

inline static inherited

## operator()() [1/2]

template<typename T>

T & operator() | ( | int | i,
|  | int | j )

inline

Alternative indexed reference to the elements Note that the indices are row first and column second. e.g. m(0,0) = 1;

## operator()() [2/2]

template<typename T>

T operator() | ( | int | i,
|  | int | j ) const

inline

Alternative indexed constant reference to the elements, Note that the indices are row first and column second. e.g. float f = m(1,0);

## operator*=() [1/2]

template<typename T>
template<typename S>

const Mat4< T > & operator*= | ( | const Mat4< S > & | m1 | ) |

inline

Multiply this matrix by the given matrix.

## operator*=() [2/2]

template<typename T>
template<typename S>

const Mat4< T > & operator*= | ( | S | scalar | ) |

inline

Multiply each element of this matrix by scalar.

## operator+=()

template<typename T>
template<typename S>

const Mat4< T > & operator+= | ( | const Mat4< S > & | m1 | ) |

inline

Add each element of the given matrix to the corresponding element of this matrix.

## operator-()

template<typename T>

Mat4< T > operator- | ( |  | ) | const

inline

Negation operator, for e.g. m1 = -m2;.

## operator-=()

template<typename T>
template<typename S>

const Mat4< T > & operator-= | ( | const Mat4< S > & | m1 | ) |

inline

Subtract each element of the given matrix from the corresponding element of this matrix.

## operator=()

template<typename T>
template<typename Source>

const Mat4 & operator= | ( | const Mat4< Source > & | m | ) |

inline

Assignment operator.

## operator[]() [1/2]

T * operator[] | ( | int | i | ) |

inline inherited

Array style reference to ith row.

## operator[]() [2/2]

const T * operator[] | ( | int | i | ) | const

inline inherited

## postRotate()

template<typename T>

void postRotate | ( | Axis | axis,
|  | T | angle )

inline

Right multiplies by a rotation clock-wiseabout the given axis into this matrix.

Parameters

  axis | The axis (one of X, Y, Z) of rotation.
  angle | The clock-wise rotation angle, in radians.

## postScale()

template<typename T>
template<typename T0>

void postScale | ( | const Vec3< T0 > & | v | ) |

inline

## postShear()

template<typename T>

void postShear | ( | Axis | axis0,
|  | Axis | axis1,
|  | T | shear )

inline

Right multiplies a shearing transformation into the matrix.

See also
  setToShear

## postTranslate()

template<typename T>
template<typename T0>

void postTranslate | ( | const Vec3< T0 > & | tr | ) |

inline

Right multiplies by the specified translation matrix, i.e. (*this) * Trans.

## preRotate()

template<typename T>

void preRotate | ( | Axis | axis,
|  | T | angle )

inline

Left multiplies by a rotation clock-wiseabout the given axis into this matrix.

Parameters

  axis | The axis (one of X, Y, Z) of rotation.
  angle | The clock-wise rotation angle, in radians.

## preScale()

template<typename T>
template<typename T0>

void preScale | ( | const Vec3< T0 > & | v | ) |

inline

## preShear()

template<typename T>

void preShear | ( | Axis | axis0,
|  | Axis | axis1,
|  | T | shear )

inline

Left multiplies a shearing transformation into the matrix.

See also
  setToShear

## pretransform() [1/2]

template<typename T>
template<typename T0>

Vec3< T0 > pretransform | ( | const Vec3< T0 > & | v | ) | const

inline

Transform a Vec3 by pre-multiplication, without homogenous division.

## pretransform() [2/2]

template<typename T>
template<typename T0>

Vec4< T0 > pretransform | ( | const Vec4< T0 > & | v | ) | const

inline

Transform a Vec4 by pre-multiplication.

## pretransformH()

template<typename T>
template<typename T0>

Vec3< T0 > pretransformH | ( | const Vec3< T0 > & | p | ) | const

inline

Transform a Vec3 by pre-multiplication, doing homogenous division.

## preTranslate()

template<typename T>
template<typename T0>

void preTranslate | ( | const Vec3< T0 > & | tr | ) |

inline

Left multiples by the specified translation, i.e. Trans * (*this).

## read()

void read | ( | std::istream & | is | ) |

inline inherited

## row()

template<typename T>

Vec4< T > row | ( | int | i | ) | const

inline

Get ith row, e.g. Vec4f v = m.row(1);.

## setCol()

template<typename T>

void setCol | ( | int | j,
|  | const Vec4< T > & | v )

inline

Set jth column to vector v.

## setColumns()

template<typename T>

void setColumns | ( | const Vec4< T > & | v1,
|  | const Vec4< T > & | v2,
|  | const Vec4< T > & | v3,
|  | const Vec4< T > & | v4 )

inline

Set the columns of this matrix to the vectors v1, v2, v3, v4.

## setIdentity()

template<typename T>

void setIdentity | ( |  | ) |

inline

Set this matrix to identity.

## setMat3()

template<typename T>

void setMat3 | ( | const Mat3< T > & | m | ) |

inline

Set upper left to a Mat3.

## setRow()

template<typename T>

void setRow | ( | int | i,
|  | const Vec4< T > & | v )

inline

Set ith row to vector v.

## setRows()

template<typename T>

void setRows | ( | const Vec4< T > & | v1,
|  | const Vec4< T > & | v2,
|  | const Vec4< T > & | v3,
|  | const Vec4< T > & | v4 )

inline

Set the rows of this matrix to the vectors v1, v2, v3, v4.

## setToRotation() [1/3]

template<typename T>

void setToRotation | ( | Axis | axis,
|  | T | angle )

inline

Sets the matrix to a rotation about the given axis.

Parameters

  axis | The axis (one of X, Y, Z) to rotate about.
  angle | The rotation angle, in radians.

## setToRotation() [2/3]

template<typename T>

void setToRotation | ( | const Vec3< T > & | axis,
|  | T | angle )

inline

Sets the matrix to a rotation about an arbitrary axis.

Parameters

  axis | The axis of rotation (cannot be zero-length)
  angle | The rotation angle, in radians.

## setToRotation() [3/3]

template<typename T>

void setToRotation | ( | const Vec3< T > & | v1,
|  | const Vec3< T > & | v2 )

inline

Sets the matrix to a rotation that maps v1 onto v2 about the cross product of v1 and v2.

## setToScale()

template<typename T>
template<typename T0>

void setToScale | ( | const Vec3< T0 > & | v | ) |

inline

Sets the matrix to a matrix that scales by v.

## setToShear()

template<typename T>

void setToShear | ( | Axis | axis0,
|  | Axis | axis1,
|  | T | shearby )

inline

Sets the matrix to a shear along axis0 by a fraction of axis1.

Parameters

  axis0 | The fixed axis of the shear.
  axis1 | The shear axis.
  shearby | The shear factor.

## setToTranslation()

template<typename T>
template<typename T0>

void setToTranslation | ( | const Vec3< T0 > & | v | ) |

inline

Sets the matrix to a matrix that translates by v.

## setTranslation()

template<typename T>

void setTranslation | ( | const Vec3< T > & | t | ) |

inline

## setZero()

template<typename T>

void setZero | ( |  | ) |

inline

## str()

std::string str | ( | unsigned | indentation = 0 | ) | const

inline inherited

Returns
  string representation of matrix Since output is multiline, optional indentation argument prefixes each newline with that much white space. It does not indent the first line, since you might be calling this inline:

cout << "matrix: " << mat.str(7)

matrix: [[1 2] [3 4]]

## transform() [1/2]

template<typename T>
template<typename T0>

Vec3< T0 > transform | ( | const Vec3< T0 > & | v | ) | const

inline

Transform a Vec3 by post-multiplication, without homogenous division.

## transform() [2/2]

template<typename T>
template<typename T0>

Vec4< T0 > transform | ( | const Vec4< T0 > & | v | ) | const

inline

Transform a Vec4 by post-multiplication.

## transform3x3()

template<typename T>
template<typename T0>

Vec3< T0 > transform3x3 | ( | const Vec3< T0 > & | v | ) | const

inline

Transform a Vec3 by post-multiplication, without translation.

## transformH()

template<typename T>
template<typename T0>

Vec3< T0 > transformH | ( | const Vec3< T0 > & | p | ) | const

inline

Transform a Vec3 by post-multiplication, doing homogenous divison.

## translation()

template<typename T>

Mat4 translation | ( | const Vec3d & | v | ) |

inline static

Sets the matrix to a matrix that translates by v.

## transpose()

template<typename T>

Mat4 transpose | ( |  | ) | const

inline

Returns
  transpose of this

## write()

void write | ( | std::ostream & | os | ) | const

inline inherited

## zero()

template<typename T>

const Mat4< T > & zero | ( |  | ) |

inline static

Predefined constant for zero matrix.

## Friends And Related Symbol Documentation

## operator!=()

template<typename T0, typename T1>

bool operator!= | ( | const Mat4< T0 > & | m0,
|  | const Mat4< T1 > & | m1 )

related

Inequality operator, does exact floating point comparisons.

## operator*() [1/7]

template<typename T, typename MT>

Vec3< typename promote< T, MT >::type > operator* | ( | const Mat4< MT > & | _m,
|  | const Vec3< T > & | _v )

related

Multiply _m by _v and return the resulting vector.

## operator*() [2/7]

template<typename T, typename MT>

Vec4< typename promote< T, MT >::type > operator* | ( | const Mat4< MT > & | _m,
|  | const Vec4< T > & | _v )

related

Multiply _m by _v and return the resulting vector.

## operator*() [3/7]

template<typename S, typename T>

Mat4< typename promote< S, T >::type > operator* | ( | const Mat4< T > & | m,
|  | S | scalar )

related

Multiply each element of the given matrix by scalar and return the result.

## operator*() [4/7]

template<typename T0, typename T1>

Mat4< typename promote< T0, T1 >::type > operator* | ( | const Mat4< T0 > & | m0,
|  | const Mat4< T1 > & | m1 )

related

Multiply m0 by m1 and return the resulting matrix.

## operator*() [5/7]

template<typename T, typename MT>

Vec3< typename promote< T, MT >::type > operator* | ( | const Vec3< T > & | _v,
|  | const Mat4< MT > & | _m )

related

Multiply _v by _m and return the resulting vector.

## operator*() [6/7]

template<typename T, typename MT>

Vec4< typename promote< T, MT >::type > operator* | ( | const Vec4< T > & | _v,
|  | const Mat4< MT > & | _m )

related

Multiply _v by _m and return the resulting vector.

## operator*() [7/7]

template<typename S, typename T>

Mat4< typename promote< S, T >::type > operator* | ( | S | scalar,
|  | const Mat4< T > & | m )

related

Multiply each element of the given matrix by scalar and return the result.

## operator+()

template<typename T0, typename T1>

Mat4< typename promote< T0, T1 >::type > operator+ | ( | const Mat4< T0 > & | m0,
|  | const Mat4< T1 > & | m1 )

related

Add corresponding elements of m0 and m1 and return the result.

## operator-()

template<typename T0, typename T1>

Mat4< typename promote< T0, T1 >::type > operator- | ( | const Mat4< T0 > & | m0,
|  | const Mat4< T1 > & | m1 )

related

Subtract corresponding elements of m0 and m1 and return the result.

## operator==()

template<typename T0, typename T1>

bool operator== | ( | const Mat4< T0 > & | m0,
|  | const Mat4< T1 > & | m1 )

related

Equality operator, does exact floating point comparisons.

## Member Data Documentation

## mm

T mm[SIZE *SIZE]

protected inherited