Om  1.0.0
A universal framework for multimedia simulation
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
om::math::MatrixND< T, 2, 2 > Class Template Reference

A class that represents a 2x2 matrix. More...

#include <omMatrix2D.h>

Public Member Functions

 MatrixND ()
 Create a 2x2 matrix with all elements equal to zero. More...
 
 MatrixND (const VectorND< T, 2 > &column1, const VectorND< T, 2 > &column2)
 Create a 2x2 matrix from two column vectors. More...
 
 MatrixND (T a, T b, T c, T d)
 Create a 2x2 matrix with elements specified in row-major order. More...
 
 MatrixND (const T array[4])
 Create a 2x2 matrix from a pointer to an array of elements in column-major order. More...
 
template<typename U >
 MatrixND (const MatrixND< U, 2, 2 > &other)
 Create a copy of the specified 2x2 matrix with different template parameter type. More...
 
T * toArrayColumnMajor ()
 Return a pointer to the matrix's elements in colunn-major order. More...
 
const T * toArrayColumnMajor () const
 Return a pointer to the matrix's elements in colunn-major order. More...
 
void toArrayRowMajor (T *outputArray) const
 Place the elements of the matrix at the location specified in row-major order. More...
 
VectorND< T, 2 > & getColumn (Index columnIndex)
 Get the column at the specified index in the matrix. More...
 
const VectorND< T, 2 > & getColumn (Index columnIndex) const
 Get the column at the specified index in the matrix. More...
 
VectorND< T, 2 > & operator() (Index columnIndex)
 Get the column at the specified index in the matrix. More...
 
const VectorND< T, 2 > & operator() (Index columnIndex) const
 Get the column at the specified index in the matrix. More...
 
VectorND< T, 2 > & operator[] (Index columnIndex)
 Get the column at the specified index in the matrix. More...
 
const VectorND< T, 2 > & operator[] (Index columnIndex) const
 Get the column at the specified index in the matrix. More...
 
VectorND< T, 2 > getRow (Index rowIndex) const
 Get the row at the specified index in the matrix. More...
 
T & get (Index columnIndex, Index rowIndex)
 Get the element at the specified (column, row) index in the matrix. More...
 
const T & get (Index columnIndex, Index rowIndex) const
 Get the element at the specified (column, row) index in the matrix. More...
 
T & operator() (Index columnIndex, Index rowIndex)
 Get the element at the specified (column, row) index in the matrix. More...
 
const T & operator() (Index columnIndex, Index rowIndex) const
 Get the element at the specified (column, row) index in the matrix. More...
 
VectorND< T, 2 > getDiagonal () const
 Return the diagonal vector of this matrix. More...
 
void set (Index columnIndex, Index rowIndex, T value)
 Set the element in the matrix at the specified (row, column) index. More...
 
void setColumn (Index columnIndex, const VectorND< T, 2 > &newColumn)
 Set the column in the matrix at the specified index. More...
 
void setRow (Index rowIndex, const VectorND< T, 2 > &newRow)
 Set the row in the matrix at the specified index. More...
 
getDeterminant () const
 Return the determinant of this matrix. More...
 
MatrixND invert (T threshold=0) const
 Return the inverse of this matrix, or the zero matrix if the matrix has no inverse. More...
 
Bool invert (MatrixND &inverse, T threshold=0) const
 Compute the inverse of this matrix, returning the result in the output parameter. More...
 
MatrixND orthonormalize () const
 Return the orthonormalization of this matrix. More...
 
MatrixND transpose () const
 Return the transposition of this matrix. More...
 
Bool operator== (const MatrixND &m) const
 Compare two matrices component-wise for equality. More...
 
Bool operator!= (const MatrixND &m) const
 Compare two matrices component-wise for inequality. More...
 
MatrixND operator- () const
 Negate every element of this matrix and return the resulting matrix. More...
 
MatrixND operator+ () const
 'Positivate' every element of this matrix, returning a copy of the original matrix. More...
 
MatrixND operator+ (const MatrixND &matrix) const
 Add this matrix to another and return the resulting matrix. More...
 
MatrixND operator+ (const T &value) const
 Add a scalar to the elements of this matrix and return the resulting matrix. More...
 
MatrixND operator- (const MatrixND &matrix) const
 Subtract a matrix from this matrix and return the resulting matrix. More...
 
MatrixND operator- (const T &value) const
 Subtract a scalar from the elements of this matrix and return the resulting matrix. More...
 
MatrixND operator* (const MatrixND &matrix) const
 Multiply a matrix by this matrix and return the result. More...
 
VectorND< T, 2 > operator* (const VectorND< T, 2 > &vector) const
 Multiply a vector/point by this matrix and return the result. More...
 
MatrixND operator* (const T &value) const
 Multiply this matrix's elements by a scalar and return the resulting matrix. More...
 
MatrixND operator/ (const T &value) const
 Divide the elements of this matrix by a scalar and return the resulting matrix. More...
 
MatrixNDoperator+= (const MatrixND &matrix2)
 Add the elements of another matrix to this matrix. More...
 
MatrixNDoperator-= (const MatrixND &matrix2)
 Subtract the elements of another matrix from this matrix. More...
 
MatrixNDoperator+= (const T &value)
 Add a scalar value to the elements of this matrix. More...
 
MatrixNDoperator-= (const T &value)
 Subtract a scalar value from the elements of this matrix. More...
 
MatrixNDoperator*= (const T &value)
 Multiply the elements of this matrix by a scalar value. More...
 
MatrixNDoperator/= (const T &value)
 Divide the elements of this matrix by a scalar value. More...
 
data::String toString () const
 Convert this 2x2 matrix into a human-readable string representation. More...
 
 operator data::String () const
 Convert this 2x2 matrix into a human-readable string representation. More...
 

Static Public Member Functions

static MatrixND rotate (T radians)
 Create a 2x2 rotation matrix with the specified rotation in radians. More...
 
static MatrixND rotateDegrees (T degrees)
 Create a 2x2 rotation matrix with the specified rotation in degrees. More...
 

Public Attributes

VectorND< T, 2 > x
 The first column vector of the matrix. More...
 
VectorND< T, 2 > y
 The second column vector of the matrix. More...
 

Static Public Attributes

static const MatrixND ZERO
 Constant matrix with all elements equal to zero. More...
 
static const MatrixND IDENTITY
 Constant matrix with diagonal elements equal to one and all others equal to zero. More...
 

Detailed Description

template<typename T>
class om::math::MatrixND< T, 2, 2 >

A class that represents a 2x2 matrix.

Elements in the matrix are stored in column-major order.

Constructor & Destructor Documentation

template<typename T >
om::math::MatrixND< T, 2, 2 >::MatrixND ( )
inline

Create a 2x2 matrix with all elements equal to zero.

template<typename T >
om::math::MatrixND< T, 2, 2 >::MatrixND ( const VectorND< T, 2 > &  column1,
const VectorND< T, 2 > &  column2 
)
inline

Create a 2x2 matrix from two column vectors.

template<typename T >
om::math::MatrixND< T, 2, 2 >::MatrixND ( a,
b,
c,
d 
)
inline

Create a 2x2 matrix with elements specified in row-major order.

template<typename T >
om::math::MatrixND< T, 2, 2 >::MatrixND ( const T  array[4])
inlineexplicit

Create a 2x2 matrix from a pointer to an array of elements in column-major order.

template<typename T >
template<typename U >
om::math::MatrixND< T, 2, 2 >::MatrixND ( const MatrixND< U, 2, 2 > &  other)
inline

Create a copy of the specified 2x2 matrix with different template parameter type.

Member Function Documentation

template<typename T >
static MatrixND om::math::MatrixND< T, 2, 2 >::rotate ( radians)
inlinestatic

Create a 2x2 rotation matrix with the specified rotation in radians.

template<typename T >
static MatrixND om::math::MatrixND< T, 2, 2 >::rotateDegrees ( degrees)
inlinestatic

Create a 2x2 rotation matrix with the specified rotation in degrees.

template<typename T >
T* om::math::MatrixND< T, 2, 2 >::toArrayColumnMajor ( )
inline

Return a pointer to the matrix's elements in colunn-major order.

Since matrix elements are stored in column-major order, no allocation is performed and the elements are accessed directly.

template<typename T >
const T* om::math::MatrixND< T, 2, 2 >::toArrayColumnMajor ( ) const
inline

Return a pointer to the matrix's elements in colunn-major order.

Since matrix elements are stored in column-major order, no allocation is performed and the elements are accessed directly.

template<typename T >
void om::math::MatrixND< T, 2, 2 >::toArrayRowMajor ( T *  outputArray) const
inline

Place the elements of the matrix at the location specified in row-major order.

The output array must be at least 4 elements long.

template<typename T >
VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::getColumn ( Index  columnIndex)
inline

Get the column at the specified index in the matrix.

template<typename T >
const VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::getColumn ( Index  columnIndex) const
inline

Get the column at the specified index in the matrix.

template<typename T >
VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::operator() ( Index  columnIndex)
inline

Get the column at the specified index in the matrix.

template<typename T >
const VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::operator() ( Index  columnIndex) const
inline

Get the column at the specified index in the matrix.

template<typename T >
VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::operator[] ( Index  columnIndex)
inline

Get the column at the specified index in the matrix.

template<typename T >
const VectorND<T,2>& om::math::MatrixND< T, 2, 2 >::operator[] ( Index  columnIndex) const
inline

Get the column at the specified index in the matrix.

template<typename T >
VectorND<T,2> om::math::MatrixND< T, 2, 2 >::getRow ( Index  rowIndex) const
inline

Get the row at the specified index in the matrix.

template<typename T >
T& om::math::MatrixND< T, 2, 2 >::get ( Index  columnIndex,
Index  rowIndex 
)
inline

Get the element at the specified (column, row) index in the matrix.

template<typename T >
const T& om::math::MatrixND< T, 2, 2 >::get ( Index  columnIndex,
Index  rowIndex 
) const
inline

Get the element at the specified (column, row) index in the matrix.

template<typename T >
T& om::math::MatrixND< T, 2, 2 >::operator() ( Index  columnIndex,
Index  rowIndex 
)
inline

Get the element at the specified (column, row) index in the matrix.

template<typename T >
const T& om::math::MatrixND< T, 2, 2 >::operator() ( Index  columnIndex,
Index  rowIndex 
) const
inline

Get the element at the specified (column, row) index in the matrix.

template<typename T >
VectorND<T,2> om::math::MatrixND< T, 2, 2 >::getDiagonal ( ) const
inline

Return the diagonal vector of this matrix.

template<typename T >
void om::math::MatrixND< T, 2, 2 >::set ( Index  columnIndex,
Index  rowIndex,
value 
)
inline

Set the element in the matrix at the specified (row, column) index.

template<typename T >
void om::math::MatrixND< T, 2, 2 >::setColumn ( Index  columnIndex,
const VectorND< T, 2 > &  newColumn 
)
inline

Set the column in the matrix at the specified index.

template<typename T >
void om::math::MatrixND< T, 2, 2 >::setRow ( Index  rowIndex,
const VectorND< T, 2 > &  newRow 
)
inline

Set the row in the matrix at the specified index.

template<typename T >
T om::math::MatrixND< T, 2, 2 >::getDeterminant ( ) const
inline

Return the determinant of this matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::invert ( threshold = 0) const
inline

Return the inverse of this matrix, or the zero matrix if the matrix has no inverse.

Whether or not the matrix is invertable is determined by comparing the determinant to a threshold - if the absolute value of the determinant is less than the threshold, the matrix is not invertable.

template<typename T >
Bool om::math::MatrixND< T, 2, 2 >::invert ( MatrixND< T, 2, 2 > &  inverse,
threshold = 0 
) const
inline

Compute the inverse of this matrix, returning the result in the output parameter.

The method returns whether or not the matrix was able to be inverted. This propery is determined by comparing the determinant to a threshold - if the absolute value of the determinant is less than the threshold, the matrix is not invertable.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::orthonormalize ( ) const
inline

Return the orthonormalization of this matrix.

This matrix that is returned has both column vectors of unit length and perpendicular to each other.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::transpose ( ) const
inline

Return the transposition of this matrix.

template<typename T >
Bool om::math::MatrixND< T, 2, 2 >::operator== ( const MatrixND< T, 2, 2 > &  m) const
inline

Compare two matrices component-wise for equality.

template<typename T >
Bool om::math::MatrixND< T, 2, 2 >::operator!= ( const MatrixND< T, 2, 2 > &  m) const
inline

Compare two matrices component-wise for inequality.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator- ( ) const
inline

Negate every element of this matrix and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator+ ( ) const
inline

'Positivate' every element of this matrix, returning a copy of the original matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator+ ( const MatrixND< T, 2, 2 > &  matrix) const
inline

Add this matrix to another and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator+ ( const T &  value) const
inline

Add a scalar to the elements of this matrix and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator- ( const MatrixND< T, 2, 2 > &  matrix) const
inline

Subtract a matrix from this matrix and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator- ( const T &  value) const
inline

Subtract a scalar from the elements of this matrix and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator* ( const MatrixND< T, 2, 2 > &  matrix) const
inline

Multiply a matrix by this matrix and return the result.

template<typename T >
VectorND<T,2> om::math::MatrixND< T, 2, 2 >::operator* ( const VectorND< T, 2 > &  vector) const
inline

Multiply a vector/point by this matrix and return the result.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator* ( const T &  value) const
inline

Multiply this matrix's elements by a scalar and return the resulting matrix.

template<typename T >
MatrixND om::math::MatrixND< T, 2, 2 >::operator/ ( const T &  value) const
inline

Divide the elements of this matrix by a scalar and return the resulting matrix.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator+= ( const MatrixND< T, 2, 2 > &  matrix2)
inline

Add the elements of another matrix to this matrix.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator-= ( const MatrixND< T, 2, 2 > &  matrix2)
inline

Subtract the elements of another matrix from this matrix.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator+= ( const T &  value)
inline

Add a scalar value to the elements of this matrix.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator-= ( const T &  value)
inline

Subtract a scalar value from the elements of this matrix.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator*= ( const T &  value)
inline

Multiply the elements of this matrix by a scalar value.

template<typename T >
MatrixND& om::math::MatrixND< T, 2, 2 >::operator/= ( const T &  value)
inline

Divide the elements of this matrix by a scalar value.

template<typename T >
data::String om::math::MatrixND< T, 2, 2 >::toString ( ) const
inline

Convert this 2x2 matrix into a human-readable string representation.

template<typename T >
om::math::MatrixND< T, 2, 2 >::operator data::String ( ) const
inline

Convert this 2x2 matrix into a human-readable string representation.

Member Data Documentation

template<typename T >
VectorND<T,2> om::math::MatrixND< T, 2, 2 >::x

The first column vector of the matrix.

template<typename T >
VectorND<T,2> om::math::MatrixND< T, 2, 2 >::y

The second column vector of the matrix.

template<typename T >
const MatrixND< T, 2, 2 > om::math::MatrixND< T, 2, 2 >::ZERO
static

Constant matrix with all elements equal to zero.

template<typename T >
const MatrixND< T, 2, 2 > om::math::MatrixND< T, 2, 2 >::IDENTITY
static

Constant matrix with diagonal elements equal to one and all others equal to zero.


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