LinearAlgebra
 All Classes Namespaces Files Functions Variables Typedefs Macros
Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
a3d::Matrix3< T, M > Struct Template Reference

A matrix of nine values for 3d calculations. More...

Collaboration diagram for a3d::Matrix3< T, M >:
Collaboration graph
[legend]

Public Member Functions

 Matrix3 ()
 Creates an uninitialized matrix. More...
 
 Matrix3 (int i)
 Creates a unit matrix. More...
 
template<class T2 , class M2 >
 Matrix3 (const Matrix3< T2, M2 > &x)
 Copy constructor. More...
 
template<class S >
 Matrix3 (S m00, S m01, S m02, S m10, S m11, S m12, S m20, S m21, S m22)
 Creates matrix from elements specified in row-major order. More...
 
template<class T2 , class M2 >
 Matrix3 (const Vector3< T2, M2 > &v0, const Vector3< T2, M2 > &v1, const Vector3< T2, M2 > &v2)
 Creates matrix from three column vectors. More...
 
 Matrix3 (const Matrix4< T, M > &x)
 Casting from Matrix4. More...
 
template<class T2 , class M2 >
 Matrix3 (const Matrix4< T2, M2 > &x)
 Casting from Matrix4. More...
 
template<class T2 , class M2 >
 Matrix3 (const Quaternion< T2, M2 > &q)
 Casting from Quaternion. More...
 
void loadIdentity ()
 Make this matrix identity, i.e. More...
 
Matrix3< T, M > transpose () const
 Creates a transposed version of the matrix. More...
 
determinant () const
 Calculates the determinant. More...
 
Matrix3< T, M > comatrix () const
 Calculates the comatrix. More...
 
Matrix3< T, M > inverse () const
 Returns the inverse of the matrix. More...
 
Matrix3< T, M > & operator= (const Matrix3< T, M > &o)
 Copy operator. More...
 
template<class T2 , class M2 >
Matrix3< T, M > & operator= (const Matrix3< T2, M2 > &o)
 Copy operator. More...
 
 operator const T * () const
 Casts this matrix to an array representation. More...
 
 operator T * ()
 Casts this matrix to an array representation. More...
 
const T & operator() (int i, int j) const
 Index access (row,col) More...
 
const T & operator[] (int i) const
 Index operator. More...
 
T & operator() (int i, int j)
 Index access (row,col) More...
 
T & operator[] (int i)
 Index operator. More...
 

Static Public Member Functions

template<class S , class T2 , class M2 >
static Matrix3< T, M > fromAxisAngle (const Vector3< T2, M2 > &v, S a)
 Creates a matrix representing a rotation around the specified axis. More...
 
template<class T2 , class M2 >
static Matrix3< T, M > fromScale (const Vector3< T2, M2 > &s)
 Creates a scaling matrix. More...
 

Public Attributes

m [9]
 Matrix cell data. More...
 

Detailed Description

template<class T, class M = Math<T>>
struct a3d::Matrix3< T, M >

A matrix of nine values for 3d calculations.

Observe that the data is stored in column-major mode for easy interfacing with OpenGL. The interfaces are specified in row-major mode (for example the constructor and print operator).

Constructor & Destructor Documentation

template<class T, class M = Math<T>>
a3d::Matrix3< T, M >::Matrix3 ( )
inline

Creates an uninitialized matrix.

template<class T, class M = Math<T>>
a3d::Matrix3< T, M >::Matrix3 ( int  i)
inlineexplicit

Creates a unit matrix.

References a3d::Matrix3< T, M >::loadIdentity().

Here is the call graph for this function:

template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Matrix3< T, M >::Matrix3 ( const Matrix3< T2, M2 > &  x)
inline

Copy constructor.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
template<class S >
a3d::Matrix3< T, M >::Matrix3 ( m00,
m01,
m02,
m10,
m11,
m12,
m20,
m21,
m22 
)
inline

Creates matrix from elements specified in row-major order.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Matrix3< T, M >::Matrix3 ( const Vector3< T2, M2 > &  v0,
const Vector3< T2, M2 > &  v1,
const Vector3< T2, M2 > &  v2 
)
inline

Creates matrix from three column vectors.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
a3d::Matrix3< T, M >::Matrix3 ( const Matrix4< T, M > &  x)
inlineexplicit
template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Matrix3< T, M >::Matrix3 ( const Matrix4< T2, M2 > &  x)
inlineexplicit
template<class T, class M = Math<T>>
template<class T2 , class M2 >
a3d::Matrix3< T, M >::Matrix3 ( const Quaternion< T2, M2 > &  q)
inlineexplicit

Member Function Documentation

template<class T, class M = Math<T>>
Matrix3<T,M> a3d::Matrix3< T, M >::comatrix ( ) const
inline

Calculates the comatrix.

References A3D_WARNING_EXPENSIVE, and a3d::Matrix3< T, M >::m.

Referenced by a3d::Matrix3< T, M >::inverse().

template<class T, class M = Math<T>>
T a3d::Matrix3< T, M >::determinant ( ) const
inline

Calculates the determinant.

References A3D_WARNING_EXPENSIVE, and a3d::Matrix3< T, M >::m.

Referenced by a3d::Matrix3< T, M >::inverse().

template<class T, class M = Math<T>>
template<class S , class T2 , class M2 >
static Matrix3<T,M> a3d::Matrix3< T, M >::fromAxisAngle ( const Vector3< T2, M2 > &  v,
a 
)
inlinestatic

Creates a matrix representing a rotation around the specified axis.

The vector represented by (x,y,z) MUST be of unit length or the result will be wrong!

References a3d::Matrix3< T, M >::m, and a3d::Vector3< T, M >::v.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
static Matrix3<T,M> a3d::Matrix3< T, M >::fromScale ( const Vector3< T2, M2 > &  s)
inlinestatic

Creates a scaling matrix.

template<class T, class M = Math<T>>
Matrix3<T,M> a3d::Matrix3< T, M >::inverse ( ) const
inline

Returns the inverse of the matrix.

This function is not optimized and is therefore extremely inefficient.

References A3D_WARNING_EXPENSIVE, a3d::Matrix3< T, M >::comatrix(), and a3d::Matrix3< T, M >::determinant().

Here is the call graph for this function:

template<class T, class M = Math<T>>
void a3d::Matrix3< T, M >::loadIdentity ( )
inline

Make this matrix identity, i.e.

ones in diagonal.

References a3d::Matrix3< T, M >::m.

Referenced by a3d::Matrix3< T, M >::Matrix3().

template<class T, class M = Math<T>>
a3d::Matrix3< T, M >::operator const T * ( ) const
inline

Casts this matrix to an array representation.

This makes it possible to provide for example a float matrix as an array argument in for example OpenGL.

Use like this:

Matrix3f m;
glGetParamv( GL_MODELVIEW_MATRIX, (float*)m );

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
a3d::Matrix3< T, M >::operator T * ( )
inline

Casts this matrix to an array representation.

This makes it possible to provide for example a float matrix as an array argument in for example OpenGL. Anything written in the returned array will end up in the matrix.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
const T& a3d::Matrix3< T, M >::operator() ( int  i,
int  j 
) const
inline

Index access (row,col)

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
T& a3d::Matrix3< T, M >::operator() ( int  i,
int  j 
)
inline

Index access (row,col)

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
Matrix3<T,M>& a3d::Matrix3< T, M >::operator= ( const Matrix3< T, M > &  o)
inline

Copy operator.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
template<class T2 , class M2 >
Matrix3<T,M>& a3d::Matrix3< T, M >::operator= ( const Matrix3< T2, M2 > &  o)
inline

Copy operator.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
const T& a3d::Matrix3< T, M >::operator[] ( int  i) const
inline

Index operator.

Access element.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
T& a3d::Matrix3< T, M >::operator[] ( int  i)
inline

Index operator.

Access element.

References a3d::Matrix3< T, M >::m.

template<class T, class M = Math<T>>
Matrix3<T,M> a3d::Matrix3< T, M >::transpose ( ) const
inline

Creates a transposed version of the matrix.

References a3d::Matrix3< T, M >::m.

Member Data Documentation

template<class T, class M = Math<T>>
T a3d::Matrix3< T, M >::m[9]