vmath  vmath-0.12
Matrix3< T > Class Template Reference

Class for matrix 3x3. More...

#include <vmath.h>

+ Collaboration diagram for Matrix3< T >:

Public Member Functions

 Matrix3 ()
 Creates identity matrix. More...
 
 Matrix3 (const T *dt)
 Copy matrix values from array (these data must be in column major order!) More...
 
 Matrix3 (const Matrix3< T > &src)
 Copy constructor. More...
 
template<class FromT >
 Matrix3 (const Matrix3< FromT > &src)
 Copy casting constructor. More...
 
void identity ()
 Resets matrix to be identity matrix. More...
 
bool operator== (const Matrix3< T > &rhs) const
 Equality test operator. More...
 
bool operator!= (const Matrix3< T > &rhs) const
 Inequality test operator. More...
 
T & at (int x, int y)
 Get reference to element at position (x,y). More...
 
const T & at (int x, int y) const
 Get constant reference to element at position (x,y). More...
 
T & operator() (int i, int j)
 Get reference to element at position (i,j), with math matrix notation. More...
 
const T & operator() (int i, int j) const
 Get constant reference to element at position (i,j), with math matrix notation. More...
 
Matrix3< T > & operator= (const Matrix3< T > &rhs)
 Copy operator. More...
 
template<class FromT >
Matrix3< T > & operator= (const Matrix3< FromT > &rhs)
 Copy casting operator. More...
 
Matrix3< T > & operator= (const T *rhs)
 Copy operator. More...
 
Matrix3< T > operator+ (const Matrix3< T > &rhs) const
 Addition operator. More...
 
Matrix3< T > operator- (const Matrix3< T > &rhs) const
 Subtraction operator. More...
 
Matrix3< T > operator+ (T rhs) const
 Addition operator. More...
 
Matrix3< T > operator- (T rhs) const
 Subtraction operator. More...
 
Matrix3< T > operator* (T rhs) const
 Multiplication operator. More...
 
Matrix3< T > operator/ (T rhs) const
 Division operator. More...
 
Vector3< T > operator* (const Vector3< T > &rhs) const
 Multiplication operator. More...
 
Matrix3< T > operator* (Matrix3< T > rhs) const
 Multiplication operator. More...
 
Matrix3< T > transpose ()
 Transpose matrix. More...
 
Matrix3< T > lerp (T fact, const Matrix3< T > &rhs) const
 Linear interpolation of two matrices. More...
 
det ()
 
Matrix3< T > inverse ()
 Computes inverse matrix. More...
 
 operator T * ()
 Conversion to pointer operator. More...
 
 operator const T * () const
 Conversion to pointer operator. More...
 
std::string toString () const
 Gets string representation. More...
 

Static Public Member Functions

static Matrix3< T > createRotationAroundAxis (T xDeg, T yDeg, T zDeg)
 Creates rotation matrix by rotation around axis. More...
 
template<class It >
static Matrix3< T > fromOde (const It *mat)
 Creates rotation matrix from ODE Matrix. More...
 
template<class FromT >
static Matrix3< T > fromRowMajorArray (const FromT *arr)
 Creates new matrix 3x3 from array that represents such matrix 3x3 as array of tightly packed elements in row major order. More...
 
template<class FromT >
static Matrix3< T > fromColumnMajorArray (const FromT *arr)
 Creates new matrix 3x3 from array that represents such matrix 3x3 as array of tightly packed elements in column major order. More...
 

Public Attributes

data [9]
 Data stored in column major order. More...
 

Friends

std::ostream & operator<< (std::ostream &lhs, const Matrix3< T > &rhs)
 Output to stream operator. More...
 

Detailed Description

template<class T>
class Matrix3< T >

Class for matrix 3x3.

Note
Data stored in this matrix are in column major order. This arrangement suits OpenGL. If you're using row major matrix, consider using fromRowMajorArray as way for construction Matrix3<T> instance.

Constructor & Destructor Documentation

template<class T>
Matrix3< T >::Matrix3 ( )
inline

Creates identity matrix.

template<class T>
Matrix3< T >::Matrix3 ( const T *  dt)
inline

Copy matrix values from array (these data must be in column major order!)

template<class T>
Matrix3< T >::Matrix3 ( const Matrix3< T > &  src)
inline

Copy constructor.

Parameters
srcData source for new created instance of Matrix3
template<class T>
template<class FromT >
Matrix3< T >::Matrix3 ( const Matrix3< FromT > &  src)
inline

Copy casting constructor.

Parameters
srcData source for new created instance of Matrix3

Member Function Documentation

template<class T>
T& Matrix3< T >::at ( int  x,
int  y 
)
inline

Get reference to element at position (x,y).

Parameters
xNumber of column (0..2)
yNumber of row (0..2)
template<class T>
const T& Matrix3< T >::at ( int  x,
int  y 
) const
inline

Get constant reference to element at position (x,y).

Parameters
xNumber of column (0..2)
yNumber of row (0..2)
template<class T>
static Matrix3<T> Matrix3< T >::createRotationAroundAxis ( xDeg,
yDeg,
zDeg 
)
inlinestatic

Creates rotation matrix by rotation around axis.

Parameters
xDegAngle (in degrees) of rotation around axis X.
yDegAngle (in degrees) of rotation around axis Y.
zDegAngle (in degrees) of rotation around axis Z.
template<class T>
T Matrix3< T >::det ( )
inline
template<class T>
template<class FromT >
static Matrix3<T> Matrix3< T >::fromColumnMajorArray ( const FromT *  arr)
inlinestatic

Creates new matrix 3x3 from array that represents such matrix 3x3 as array of tightly packed elements in column major order.

Parameters
arrAn array of elements for 3x3 matrix in column major order.
Returns
An instance of Matrix3<T> representing arr
template<class T>
template<class It >
static Matrix3<T> Matrix3< T >::fromOde ( const It *  mat)
inlinestatic

Creates rotation matrix from ODE Matrix.

template<class T>
template<class FromT >
static Matrix3<T> Matrix3< T >::fromRowMajorArray ( const FromT *  arr)
inlinestatic

Creates new matrix 3x3 from array that represents such matrix 3x3 as array of tightly packed elements in row major order.

Parameters
arrAn array of elements for 3x3 matrix in row major order.
Returns
An instance of Matrix3<T> representing arr
template<class T>
void Matrix3< T >::identity ( )
inline

Resets matrix to be identity matrix.

template<class T>
Matrix3<T> Matrix3< T >::inverse ( )
inline

Computes inverse matrix.

Returns
Inverse matrix of this matrix.
template<class T>
Matrix3<T> Matrix3< T >::lerp ( fact,
const Matrix3< T > &  rhs 
) const
inline

Linear interpolation of two matrices.

Parameters
factFactor of interpolation. For translation from positon of this matrix (lhs) to matrix rhs, values of factor goes from 0.0 to 1.0.
rhsSecond Matrix for interpolation
Note
However values of fact parameter are reasonable only in interval [0.0 , 1.0], you can pass also values outside of this interval and you can get result (extrapolation?)
template<class T>
Matrix3< T >::operator const T * ( ) const
inline

Conversion to pointer operator.

Returns
Constant Pointer to internally stored (in management of class Matrix3<T>) used for passing Matrix3<T> values to gl*[fd]v functions.
template<class T>
Matrix3< T >::operator T * ( )
inline

Conversion to pointer operator.

Returns
Pointer to internally stored (in management of class Matrix3<T>) used for passing Matrix3<T> values to gl*[fd]v functions.
template<class T>
bool Matrix3< T >::operator!= ( const Matrix3< T > &  rhs) const
inline

Inequality test operator.

Parameters
rhsRight hand side argument of binary operator.
Returns
not (lhs == rhs) :-P
template<class T>
T& Matrix3< T >::operator() ( int  i,
int  j 
)
inline

Get reference to element at position (i,j), with math matrix notation.

Parameters
iNumber of row (1..3)
jNumber of column (1..3)
template<class T>
const T& Matrix3< T >::operator() ( int  i,
int  j 
) const
inline

Get constant reference to element at position (i,j), with math matrix notation.

Parameters
iNumber of row (1..3)
jNumber of column (1..3)
template<class T>
Matrix3<T> Matrix3< T >::operator* ( rhs) const
inline

Multiplication operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Vector3<T> Matrix3< T >::operator* ( const Vector3< T > &  rhs) const
inline

Multiplication operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator* ( Matrix3< T >  rhs) const
inline

Multiplication operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator+ ( const Matrix3< T > &  rhs) const
inline

Addition operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator+ ( rhs) const
inline

Addition operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator- ( const Matrix3< T > &  rhs) const
inline

Subtraction operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator- ( rhs) const
inline

Subtraction operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T> Matrix3< T >::operator/ ( rhs) const
inline

Division operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T>& Matrix3< T >::operator= ( const Matrix3< T > &  rhs)
inline

Copy operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
template<class FromT >
Matrix3<T>& Matrix3< T >::operator= ( const Matrix3< FromT > &  rhs)
inline

Copy casting operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
Matrix3<T>& Matrix3< T >::operator= ( const T *  rhs)
inline

Copy operator.

Parameters
rhsRight hand side argument of binary operator.
template<class T>
bool Matrix3< T >::operator== ( const Matrix3< T > &  rhs) const
inline

Equality test operator.

Parameters
rhsRight hand side argument of binary operator.
Note
Test of equality is based of threshold EPSILON value. To be two values equal, must satisfy this condition all elements of matrix | lhs[i] - rhs[i] | < EPSILON, same for y-coordinate, z-coordinate, and w-coordinate.
template<class T>
std::string Matrix3< T >::toString ( ) const
inline

Gets string representation.

template<class T>
Matrix3<T> Matrix3< T >::transpose ( )
inline

Transpose matrix.

Friends And Related Function Documentation

template<class T>
std::ostream& operator<< ( std::ostream &  lhs,
const Matrix3< T > &  rhs 
)
friend

Output to stream operator.

Parameters
lhsLeft hand side argument of operator (commonly ostream instance).
rhsRight hand side argument of operator.
Returns
Left hand side argument - the ostream object passed to operator.

Member Data Documentation

template<class T>
T Matrix3< T >::data[9]

Data stored in column major order.


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