OpenVDB  4.0.1
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | Related Functions | List of all members
Mat3< T > Class Template Reference

3x3 matrix class. More...

#include <Mat3.h>

Inherits Mat< 3, T >.

Public Types

typedef T value_type
 Data type held by the matrix. More...
 
typedef T ValueType
 
typedef Mat< 3, T > MyBase
 
enum  SIZE_
 

Public Member Functions

 Mat3 ()
 Trivial constructor, the matrix is NOT initialized. More...
 
 Mat3 (const Quat< T > &q)
 
template<typename Source >
 Mat3 (Source a, Source b, Source c, Source d, Source e, Source f, Source g, Source h, Source i)
 Constructor given array of elements, the ordering is in row major form: More...
 
template<typename Source >
 Mat3 (const Vec3< Source > &v1, const Vec3< Source > &v2, const Vec3< Source > &v3, bool rows=true)
 
template<typename Source >
 Mat3 (Source *a)
 
 Mat3 (const Mat< 3, T > &m)
 Copy constructor. More...
 
template<typename Source >
 Mat3 (const Mat3< Source > &m)
 Conversion constructor. More...
 
 Mat3 (const Mat4< T > &m)
 Conversion from Mat4 (copies top left) More...
 
void setRow (int i, const Vec3< T > &v)
 Set ith row to vector v. More...
 
Vec3< T > row (int i) const
 Get ith row, e.g. Vec3d v = m.row(1);. More...
 
void setCol (int j, const Vec3< T > &v)
 Set jth column to vector v. More...
 
Vec3< T > col (int j) const
 Get jth column, e.g. Vec3d v = m.col(0);. More...
 
T * asPointer ()
 
const T * asPointer () const
 
T & operator() (int i, int j)
 
operator() (int i, int j) const
 
void setRows (const Vec3< T > &v1, const Vec3< T > &v2, const Vec3< T > &v3)
 Set the rows of "this" matrix to the vectors v1, v2, v3. More...
 
void setColumns (const Vec3< T > &v1, const Vec3< T > &v2, const Vec3< T > &v3)
 Set the columns of "this" matrix to the vectors v1, v2, v3. More...
 
OPENVDB_DEPRECATED void setBasis (const Vec3< T > &v1, const Vec3< T > &v2, const Vec3< T > &v3)
 Set the rows of "this" matrix to the vectors v1, v2, v3. More...
 
void setSymmetric (const Vec3< T > &vdiag, const Vec3< T > &vtri)
 Set diagonal and symmetric triangular components. More...
 
void setSkew (const Vec3< T > &v)
 Set the matrix as cross product of the given vector. More...
 
void setToRotation (const Quat< T > &q)
 Set this matrix to the rotation matrix specified by the quaternion. More...
 
void setToRotation (const Vec3< T > &axis, T angle)
 Set this matrix to the rotation specified by axis and angle. More...
 
void setZero ()
 Set this matrix to zero. More...
 
void setIdentity ()
 Set "this" matrix to identity. More...
 
template<typename Source >
const Mat3operator= (const Mat3< Source > &m)
 Assignment operator. More...
 
bool eq (const Mat3 &m, T eps=1.0e-8) const
 Test if "this" is equivalent to m with tolerance of eps value. More...
 
Mat3< T > operator- () const
 Negation operator, for e.g. m1 = -m2;. More...
 
template<typename S >
const Mat3< T > & operator*= (S scalar)
 Multiplication operator, e.g. M = scalar * M;. More...
 
template<typename S >
const Mat3< T > & operator+= (const Mat3< S > &m1)
 Returns m0, where $m0_{i,j} += m1_{i,j}$ for $i, j \in [0, 2]$. More...
 
template<typename S >
const Mat3< T > & operator-= (const Mat3< S > &m1)
 Returns m0, where $m0_{i,j} -= m1_{i,j}$ for $i, j \in [0, 2]$. More...
 
template<typename S >
const Mat3< T > & operator*= (const Mat3< S > &m1)
 Returns m0, where $m0_{i,j} *= m1_{i,j}$ for $i, j \in [0, 2]$. More...
 
Mat3 cofactor () const
 Return the cofactor matrix of "this". More...
 
Mat3 adjoint () const
 returns adjoint of "this", i.e. the transpose of the cofactor of "this" More...
 
Mat3 transpose () const
 returns transpose of this More...
 
Mat3 inverse (T tolerance=0) const
 
det () const
 Determinant of matrix. More...
 
trace () const
 Trace of matrix. More...
 
Mat3 snapBasis (Axis axis, const Vec3< T > &direction)
 
template<typename T0 >
Vec3< T0 > transform (const Vec3< T0 > &v) const
 
template<typename T0 >
Vec3< T0 > pretransform (const Vec3< T0 > &v) const
 
Mat3 timesDiagonal (const Vec3< T > &diag) const
 
std::string str (unsigned indentation=0) const
 
void write (std::ostream &os) const
 
void read (std::istream &is)
 
absMax () const
 Return the maximum of the absolute of all elements in this matrix. More...
 
T * operator[] (int i)
 
const T * operator[] (int i) const
 

Static Public Member Functions

static const Mat3< T > & identity ()
 Predefined constant for identity matrix. More...
 
static const Mat3< T > & zero ()
 Predefined constant for zero matrix. More...
 
static Mat3 symmetric (const Vec3< T > &vdiag, const Vec3< T > &vtri)
 
static unsigned numRows ()
 
static unsigned numColumns ()
 
static unsigned numElements ()
 

Protected Attributes

mm [SIZE *SIZE]
 

Related Functions

(Note that these are not member functions.)

template<typename T0 , typename T1 >
bool operator== (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Equality operator, does exact floating point comparisons. More...
 
template<typename T0 , typename T1 >
bool operator!= (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Inequality operator, does exact floating point comparisons. More...
 
template<typename S , typename T >
Mat3< typename promote< S, T >::type > operator* (S scalar, const Mat3< T > &m)
 Returns M, where $M_{i,j} = m_{i,j} * scalar$ for $i, j \in [0, 2]$. More...
 
template<typename S , typename T >
Mat3< typename promote< S, T >::type > operator* (const Mat3< T > &m, S scalar)
 Returns M, where $M_{i,j} = m_{i,j} * scalar$ for $i, j \in [0, 2]$. More...
 
template<typename T0 , typename T1 >
Mat3< typename promote< T0, T1 >::type > operator+ (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Returns M, where $M_{i,j} = m0_{i,j} + m1_{i,j}$ for $i, j \in [0, 2]$. More...
 
template<typename T0 , typename T1 >
Mat3< typename promote< T0, T1 >::type > operator- (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Returns M, where $M_{i,j} = m0_{i,j} - m1_{i,j}$ for $i, j \in [0, 2]$. More...
 
template<typename T , typename MT >
Vec3< typename promote< T, MT >::type > operator* (const Mat3< MT > &_m, const Vec3< T > &_v)
 Returns v, where $v_{i} = \sum_{n=0}^2 m_{i,n} * v_n$ for $i \in [0, 2]$. More...
 
template<typename T , typename MT >
Vec3< typename promote< T, MT >::type > operator* (const Vec3< T > &_v, const Mat3< MT > &_m)
 Returns v, where $v_{i} = \sum_{n=0}^2 m_{n,i} * v_n$ for $i \in [0, 2]$. More...
 
template<typename T , typename MT >
Vec3< T > & operator*= (Vec3< T > &_v, const Mat3< MT > &_m)
 Returns v, where $v_{i} = \sum_{n=0}^2 m_{i,n} * v_n$ for $i \in [0, 2]$. More...
 

Detailed Description

template<typename T>
class openvdb::v4_0_1::math::Mat3< T >

3x3 matrix class.

Member Typedef Documentation

typedef Mat<3, T> MyBase
typedef T value_type

Data type held by the matrix.

typedef T ValueType

Member Enumeration Documentation

enum SIZE_
inherited

Constructor & Destructor Documentation

Mat3 ( )
inline

Trivial constructor, the matrix is NOT initialized.

Mat3 ( const Quat< T > &  q)
inline

Constructor given the quaternion rotation, e.g. Mat3f m(q); The quaternion is normalized and used to construct the matrix

Mat3 ( Source  a,
Source  b,
Source  c,
Source  d,
Source  e,
Source  f,
Source  g,
Source  h,
Source  i 
)
inline

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

a b c
d e f
g h i
Mat3 ( const Vec3< Source > &  v1,
const Vec3< Source > &  v2,
const Vec3< Source > &  v3,
bool  rows = true 
)
inline

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

Mat3 ( 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]

Mat3 ( const Mat< 3, T > &  m)
inline

Copy constructor.

Mat3 ( const Mat3< Source > &  m)
inlineexplicit

Conversion constructor.

Mat3 ( const Mat4< T > &  m)
inlineexplicit

Conversion from Mat4 (copies top left)

Member Function Documentation

T absMax ( ) const
inlineinherited

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

Mat3 adjoint ( ) const
inline

returns adjoint of "this", i.e. the transpose of the cofactor of "this"

T* asPointer ( )
inline
const T* asPointer ( ) const
inline
Mat3 cofactor ( ) const
inline

Return the cofactor matrix of "this".

Vec3<T> col ( int  j) const
inline

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

T det ( ) const
inline

Determinant of matrix.

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

Test if "this" is equivalent to m with tolerance of eps value.

static const Mat3<T>& identity ( )
inlinestatic

Predefined constant for identity matrix.

Mat3 inverse ( tolerance = 0) const
inline

returns inverse of this

Exceptions
ArithmeticErrorif singular
static unsigned numColumns ( )
inlinestaticinherited
static unsigned numElements ( )
inlinestaticinherited
static unsigned numRows ( )
inlinestaticinherited
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;

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

const Mat3<T>& operator*= ( scalar)
inline

Multiplication operator, e.g. M = scalar * M;.

Returns m, where $m_{i,j} *= scalar$ for $i, j \in [0, 2]$

const Mat3<T>& operator*= ( const Mat3< S > &  m1)
inline

Returns m0, where $m0_{i,j} *= m1_{i,j}$ for $i, j \in [0, 2]$.

const Mat3<T>& operator+= ( const Mat3< S > &  m1)
inline

Returns m0, where $m0_{i,j} += m1_{i,j}$ for $i, j \in [0, 2]$.

Mat3<T> operator- ( ) const
inline

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

const Mat3<T>& operator-= ( const Mat3< S > &  m1)
inline

Returns m0, where $m0_{i,j} -= m1_{i,j}$ for $i, j \in [0, 2]$.

const Mat3& operator= ( const Mat3< Source > &  m)
inline

Assignment operator.

T* operator[] ( int  i)
inline

Array style reference to ith row e.g. m[1][2] = 4;

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

Array style reference to ith row e.g. m[1][2] = 4;

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

Return the transformed vector by transpose of "this" matrix. This function is equivalent to pre-multiplying the matrix.

void read ( std::istream &  is)
inlineinherited
Vec3<T> row ( int  i) const
inline

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

OPENVDB_DEPRECATED void setBasis ( const Vec3< T > &  v1,
const Vec3< T > &  v2,
const Vec3< T > &  v3 
)
inline

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

void setCol ( int  j,
const Vec3< T > &  v 
)
inline

Set jth column to vector v.

void setColumns ( const Vec3< T > &  v1,
const Vec3< T > &  v2,
const Vec3< T > &  v3 
)
inline

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

void setIdentity ( )
inline

Set "this" matrix to identity.

void setRow ( int  i,
const Vec3< T > &  v 
)
inline

Set ith row to vector v.

void setRows ( const Vec3< T > &  v1,
const Vec3< T > &  v2,
const Vec3< T > &  v3 
)
inline

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

void setSkew ( const Vec3< T > &  v)
inline

Set the matrix as cross product of the given vector.

void setSymmetric ( const Vec3< T > &  vdiag,
const Vec3< T > &  vtri 
)
inline

Set diagonal and symmetric triangular components.

void setToRotation ( const Quat< T > &  q)
inline

Set this matrix to the rotation matrix specified by the quaternion.

The quaternion is normalized and used to construct the matrix. Note that the matrix is transposed to match post-multiplication semantics.

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

Set this matrix to the rotation specified by axis and angle.

The axis must be unit vector

void setZero ( )
inline

Set this matrix to zero.

Mat3 snapBasis ( Axis  axis,
const Vec3< T > &  direction 
)
inline

This function snaps a specific axis to a specific direction, preserving scaling. It does this using minimum energy, thus posing a unique solution if basis & direction arent parralel. Direction need not be unit.

std::string str ( unsigned  indentation = 0) const
inlineinherited
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]]

static Mat3 symmetric ( const Vec3< T > &  vdiag,
const Vec3< T > &  vtri 
)
inlinestatic

Returns matrix with prescribed diagonal and symmetric triangular components

Mat3 timesDiagonal ( const Vec3< T > &  diag) const
inline

Treats diag as a diagonal matrix and returns the multiplication of "this" with diag (from the right).

T trace ( ) const
inline

Trace of matrix.

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

Return the transformed vector by "this" matrix. This function is equivalent to post-multiplying the matrix.

Mat3 transpose ( ) const
inline

returns transpose of this

void write ( std::ostream &  os) const
inlineinherited
static const Mat3<T>& zero ( )
inlinestatic

Predefined constant for zero matrix.

Friends And Related Function Documentation

bool operator!= ( const Mat3< T0 > &  m0,
const Mat3< T1 > &  m1 
)
related

Inequality operator, does exact floating point comparisons.

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

Returns M, where $M_{i,j} = m_{i,j} * scalar$ for $i, j \in [0, 2]$.

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

Returns M, where $M_{i,j} = m_{i,j} * scalar$ for $i, j \in [0, 2]$.

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

Returns v, where $v_{i} = \sum_{n=0}^2 m_{i,n} * v_n$ for $i \in [0, 2]$.

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

Returns v, where $v_{i} = \sum_{n=0}^2 m_{n,i} * v_n$ for $i \in [0, 2]$.

Vec3< T > & operator*= ( Vec3< T > &  _v,
const Mat3< MT > &  _m 
)
related

Returns v, where $v_{i} = \sum_{n=0}^2 m_{i,n} * v_n$ for $i \in [0, 2]$.

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

Returns M, where $M_{i,j} = m0_{i,j} + m1_{i,j}$ for $i, j \in [0, 2]$.

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

Returns M, where $M_{i,j} = m0_{i,j} - m1_{i,j}$ for $i, j \in [0, 2]$.

bool operator== ( const Mat3< T0 > &  m0,
const Mat3< T1 > &  m1 
)
related

Equality operator, does exact floating point comparisons.

Member Data Documentation

T mm[SIZE *SIZE]
protectedinherited

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