HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T > Class Template Reference

3x3 matrix class. More...

#include <Mat3.h>

+ Inheritance diagram for openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >:

Public Types

using value_type = T
 Data type held by the matrix. More...
 
using ValueType = T
 
using MyBase = Mat< 3, T >
 
- Public Types inherited from openvdb::OPENVDB_VERSION_NAME::math::Mat< 3, T >
enum  SIZE_
 
using value_type = T
 
using ValueType = T
 

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...
 
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
 Return true if this matrix is equivalent to m within a tolerance of eps. 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)
 Add each element of the given matrix to the corresponding element of this matrix. More...
 
template<typename S >
const Mat3< T > & operator-= (const Mat3< S > &m1)
 Subtract each element of the given matrix from the corresponding element of this matrix. More...
 
template<typename S >
const Mat3< T > & operator*= (const Mat3< S > &m1)
 Multiply this matrix by the given matrix. More...
 
Mat3 cofactor () const
 Return the cofactor matrix of this matrix. More...
 
Mat3 adjoint () const
 Return the adjoint of this matrix, i.e., the transpose of its cofactor. 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
 Treat diag as a diagonal matrix and return the product of this matrix with diag (from the right). More...
 
T * operator[] (int i)
 
const T * operator[] (int i) const
 
- Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::math::Mat< 3, T >
 Mat ()
 
 Mat (Mat const &src)
 Copy constructor. Used when the class signature matches exactly. More...
 
Matoperator= (Mat const &src)
 
std::string str (unsigned indentation=0) 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. More...
 
bool isNan () const
 True if a Nan is present in this matrix. More...
 
bool isInfinite () const
 True if an Inf is present in this matrix. More...
 
bool isFinite () const
 True if no Nan or Inf values are present. More...
 
bool isZero () const
 True if all elements are exactly zero. More...
 

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)
 Return a matrix with the prescribed diagonal and symmetric triangular components. More...
 
- Static Public Member Functions inherited from openvdb::OPENVDB_VERSION_NAME::math::Mat< 3, T >
static unsigned numRows ()
 
static unsigned numColumns ()
 
static unsigned numElements ()
 

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)
 Multiply each element of the given matrix by scalar and return the result. More...
 
template<typename S , typename T >
Mat3< typename promote< S, T >
::type
operator* (const Mat3< T > &m, S scalar)
 Multiply each element of the given matrix by scalar and return the result. More...
 
template<typename T0 , typename T1 >
Mat3< typename promote< T0, T1 >
::type
operator+ (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Add corresponding elements of m0 and m1 and return the result. More...
 
template<typename T0 , typename T1 >
Mat3< typename promote< T0, T1 >
::type
operator- (const Mat3< T0 > &m0, const Mat3< T1 > &m1)
 Subtract corresponding elements of m0 and m1 and return the result. More...
 
template<typename T , typename MT >
Vec3< typename promote< T, MT >
::type
operator* (const Mat3< MT > &_m, const Vec3< T > &_v)
 Multiply _m by _v and return the resulting vector. More...
 
template<typename T , typename MT >
Vec3< typename promote< T, MT >
::type
operator* (const Vec3< T > &_v, const Mat3< MT > &_m)
 Multiply _v by _m and return the resulting vector. More...
 
template<typename T , typename MT >
Vec3< T > & operator*= (Vec3< T > &_v, const Mat3< MT > &_m)
 Multiply _v by _m and replace _v with the resulting vector. More...
 

Additional Inherited Members

- Protected Attributes inherited from openvdb::OPENVDB_VERSION_NAME::math::Mat< 3, T >
T mm [SIZE *SIZE]
 

Detailed Description

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

3x3 matrix class.

Definition at line 55 of file Mat3.h.

Member Typedef Documentation

template<typename T>
using openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::MyBase = Mat<3, T>

Definition at line 61 of file Mat3.h.

template<typename T>
using openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::value_type = T

Data type held by the matrix.

Definition at line 59 of file Mat3.h.

template<typename T>
using openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::ValueType = T

Definition at line 60 of file Mat3.h.

Constructor & Destructor Documentation

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::Mat3 ( )
inline

Trivial constructor, the matrix is NOT initialized.

Definition at line 63 of file Mat3.h.

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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

Definition at line 67 of file Mat3.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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

Definition at line 78 of file Mat3.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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)

Definition at line 96 of file Mat3.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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]

Definition at line 110 of file Mat3.h.

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::Mat3 ( const Mat< 3, T > &  m)
inline

Copy constructor.

Definition at line 124 of file Mat3.h.

template<typename T>
template<typename Source >
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::Mat3 ( const Mat3< Source > &  m)
inlineexplicit

Conversion constructor.

Definition at line 135 of file Mat3.h.

template<typename T>
openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::Mat3 ( const Mat4< T > &  m)
inlineexplicit

Conversion from Mat4 (copies top left)

Definition at line 145 of file Mat3.h.

Member Function Documentation

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::adjoint ( ) const
inline

Return the adjoint of this matrix, i.e., the transpose of its cofactor.

Definition at line 486 of file Mat3.h.

template<typename T>
T* openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::asPointer ( )
inline

Definition at line 219 of file Mat3.h.

template<typename T>
const T* openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::asPointer ( ) const
inline

Definition at line 220 of file Mat3.h.

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::cofactor ( ) const
inline

Return the cofactor matrix of this matrix.

Definition at line 471 of file Mat3.h.

template<typename T>
Vec3<T> openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::col ( int  j) const
inline

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

Definition at line 202 of file Mat3.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::det ( ) const
inline

Determinant of matrix.

Definition at line 527 of file Mat3.h.

template<typename T>
bool openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::eq ( const Mat3< T > &  m,
eps = 1.0e-8 
) const
inline

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

Definition at line 349 of file Mat3.h.

template<typename T>
static const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::identity ( )
inlinestatic

Predefined constant for identity matrix.

Definition at line 155 of file Mat3.h.

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::inverse ( tolerance = 0) const
inline

returns inverse of this

Exceptions
ArithmeticErrorif singular

Definition at line 513 of file Mat3.h.

template<typename T>
T& openvdb::OPENVDB_VERSION_NAME::math::Mat3< 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;

Definition at line 225 of file Mat3.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Mat3< 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);

Definition at line 235 of file Mat3.h.

template<typename T>
template<typename S >
const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator*= ( scalar)
inline

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

Multiply each element of this matrix by scalar.

Definition at line 379 of file Mat3.h.

template<typename T>
template<typename S >
const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator*= ( const Mat3< S > &  m1)
inline

Multiply this matrix by the given matrix.

Definition at line 431 of file Mat3.h.

template<typename T>
template<typename S >
const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator+= ( const Mat3< S > &  m1)
inline

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

Definition at line 395 of file Mat3.h.

template<typename T>
Mat3<T> openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator- ( ) const
inline

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

Definition at line 363 of file Mat3.h.

template<typename T>
template<typename S >
const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator-= ( const Mat3< S > &  m1)
inline

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

Definition at line 413 of file Mat3.h.

template<typename T>
template<typename Source >
const Mat3& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator= ( const Mat3< Source > &  m)
inline

Assignment operator.

Definition at line 339 of file Mat3.h.

template<typename T>
T* openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator[] ( int  i)
inline

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

Definition at line 215 of file Mat3.h.

template<typename T>
const T* openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::operator[] ( int  i) const
inline

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

Definition at line 216 of file Mat3.h.

template<typename T>
template<typename T0 >
Vec3<T0> openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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.

Definition at line 561 of file Mat3.h.

template<typename T>
Vec3<T> openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::row ( int  i) const
inline

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

Definition at line 186 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setCol ( int  j,
const Vec3< T > &  v 
)
inline

Set jth column to vector v.

Definition at line 193 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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.

Definition at line 257 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setIdentity ( )
inline

Set this matrix to identity.

Definition at line 324 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setRow ( int  i,
const Vec3< T > &  v 
)
inline

Set ith row to vector v.

Definition at line 175 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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.

Definition at line 243 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setSkew ( const Vec3< T > &  v)
inline

Set the matrix as cross product of the given vector.

Definition at line 295 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setSymmetric ( const Vec3< T > &  vdiag,
const Vec3< T > &  vtri 
)
inline

Set diagonal and symmetric triangular components.

Definition at line 271 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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.

Definition at line 301 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setToRotation ( const Vec3< T > &  axis,
angle 
)
inline

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

The axis must be unit vector

Definition at line 306 of file Mat3.h.

template<typename T>
void openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::setZero ( )
inline

Set this matrix to zero.

Definition at line 310 of file Mat3.h.

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::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.

Definition at line 545 of file Mat3.h.

template<typename T>
static Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::symmetric ( const Vec3< T > &  vdiag,
const Vec3< T > &  vtri 
)
inlinestatic

Return a matrix with the prescribed diagonal and symmetric triangular components.

Definition at line 285 of file Mat3.h.

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::timesDiagonal ( const Vec3< T > &  diag) const
inline

Treat diag as a diagonal matrix and return the product of this matrix with diag (from the right).

Definition at line 569 of file Mat3.h.

template<typename T>
T openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::trace ( ) const
inline

Trace of matrix.

Definition at line 536 of file Mat3.h.

template<typename T>
template<typename T0 >
Vec3<T0> openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::transform ( const Vec3< T0 > &  v) const
inline

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

Definition at line 553 of file Mat3.h.

template<typename T>
Mat3 openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::transpose ( ) const
inline

returns transpose of this

Definition at line 502 of file Mat3.h.

template<typename T>
static const Mat3<T>& openvdb::OPENVDB_VERSION_NAME::math::Mat3< T >::zero ( )
inlinestatic

Predefined constant for zero matrix.

Definition at line 165 of file Mat3.h.

Friends And Related Function Documentation

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

Inequality operator, does exact floating point comparisons.

Definition at line 604 of file Mat3.h.

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

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

Definition at line 609 of file Mat3.h.

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

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

Definition at line 615 of file Mat3.h.

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

Multiply _m by _v and return the resulting vector.

Definition at line 656 of file Mat3.h.

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

Multiply _v by _m and return the resulting vector.

Definition at line 669 of file Mat3.h.

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

Multiply _v by _m and replace _v with the resulting vector.

Definition at line 681 of file Mat3.h.

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

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

Definition at line 625 of file Mat3.h.

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

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

Definition at line 635 of file Mat3.h.

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

Equality operator, does exact floating point comparisons.

Definition at line 590 of file Mat3.h.


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