NxM-dimensional matrix class template of fixed dimensions. More...
Public Types | |
enum | Transposed_copy_tag { TRANSPOSED_COPY_TAG } |
Enum type used to tag a special copy constructor that transposes the matrix while copying. More... |
|
typedef Matrix_struct< T, ROW, COL > |
Pod_type |
POD class corresponding to this matrix. More... |
|
typedef Matrix_struct< T, ROW, COL > |
storage_type |
Storage class used by this matrix. More... |
|
typedef T | value_type |
Element type. More... |
|
typedef Size | size_type |
Size type, unsigned. More... |
|
typedef Difference | difference_type |
Difference type, signed. More... |
|
typedef T * | pointer |
Mutable pointer to element. More... |
|
typedef const T * | const_pointer |
Const pointer to element. More... |
|
typedef T & | reference |
Mutable reference to element. More... |
|
typedef const T & | const_reference |
Const reference to element. More... |
|
typedef Vector< T, COL > | Row_vector |
Associated row vector of dimension COL . More... |
|
typedef Vector< T, ROW > | Column_vector |
Associated column vector of dimension ROW . More... |
|
Public Member Functions | |
T * | begin () |
Returns the pointer to the first matrix element. More... |
|
T const * | begin () const |
Returns the pointer to the first matrix element. More... |
|
T * | end () |
Returns the past-the-end pointer. More... |
|
T const * | end () const |
Returns the past-the-end pointer. More... |
|
Row_vector & | operator[] (Size row) |
Accesses the row-th row vector, 0 <= row < ROW . More... |
|
const Row_vector & | operator[] (Size row) const |
Accesses the row-th row vector, 0 <= row < ROW . More... |
|
Matrix () | |
The default constructor leaves the vector elements uninitialized. More... |
|
Matrix (const Matrix_struct< T, ROW, COL > &other) | |
Constructor from underlying storage type. More... |
|
Matrix (T diag) | |
Constructor initializes all matrix elements to zero and the diagonal elements to diag . More... |
|
template<typename Iterator > | |
Matrix (From_iterator_tag, Iterator p) | |
Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the matrix elements with the first ROW times COL elements from the sequence starting at the iterator p . More... |
|
template<typename T2 > | |
Matrix (T2 const (&array)[SIZE]) | |
Constructor initializes the matrix elements from an array of dimension ROW times COL . More... |
|
template<typename T2 > | |
Matrix (const Matrix< T2, ROW, COL > &other) | |
Template constructor that allows explicit conversions from other matrices with assignment compatible element value type. More... |
|
Matrix (Transposed_copy_tag, const Matrix< T, COL, ROW > &other) | |
Constructor that initializes the matrix with the transpose matrix of other . More... |
|
template<typename T2 > | |
Matrix (Transposed_copy_tag, const Matrix< T2, COL, ROW > &other) | |
Template constructor that initializes the matrix with the transpose matrix of other that allows the explicit conversions from other matrices with assignment compatible element value type. More... |
|
Matrix (const Row_vector &v0) | |
Dedicated constructor, for ROW==1 only, that initializes matrix from one row vector v0 . More... |
|
Matrix (const Row_vector &v0, const Row_vector &v1) | |
Dedicated constructor, for ROW==2 only, that initializes matrix from two row vectors (v0,v1). More... |
|
Matrix (const Row_vector &v0, const Row_vector &v1, const Row_vector &v2) | |
Dedicated constructor, for ROW==3 only, that initializes matrix from three row vectors (v0,v1,v2). More... |
|
Matrix (const Row_vector &v0, const Row_vector &v1, const Row_vector &v2, const Row_vector &v3) | |
Dedicated constructor, for ROW==4 only, that initializes matrix from four row vectors (v0,v1,v2,v3). More... |
|
Matrix (T m0, T m1) | |
2-element constructor, must be a 1x2 or 2x1 matrix. More... |
|
Matrix (T m0, T m1, T m2) | |
3-element constructor, must be a 1x3 or 3x1 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3) | |
4-element constructor, must be a 1x4, 2x2, or 4x1 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3, T m4, T m5) | |
6-element constructor, must be a 2x3 or 3x2 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3, T m4, T m5, T m6, T m7) | |
8-element constructor, must be a 2x4 or 4x2 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3, T m4, T m5, T m6, T m7, T m8) | |
9-element constructor, must be a 3x3 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3, T m4, T m5, T m6, T m7, T m8, T m9, T m10, T m11) | |
12-element constructor, must be a 3x4 or 4x3 matrix. More... |
|
Matrix (T m0, T m1, T m2, T m3, T m4, T m5, T m6, T m7, T m8, T m9, T m10, T m11, T m12, T m13, T m14, T m15) | |
16-element constructor, must be a 4x4 matrix. More... |
|
Matrix & | operator= (const Matrix &other) |
Assignment. More... |
|
T & | operator() (Size row, Size col) |
Accesses the (row ,col )-th matrix element. More... |
|
const T & | operator() (Size row, Size col) const |
Accesses the (row , col )-th matrix element. More... |
|
T | get (Size i) const |
Accesses the i-th matrix element, indexed in the order of the row-major memory layout. More... |
|
T | get (Size row, Size col) const |
Accesses the (row , col )-th matrix element. More... |
|
void | set (Size i, T value) |
Sets the i-th matrix element to value , indexed in the order of the row-major memory layout. More... |
|
void | set (Size row, Size col, T value) |
Sets the i-th matrix element to value , indexed in the order of the row-major memory layout. More... |
|
T | det33 () const |
Returns the determinant of the upper-left 3x3 sub-matrix. More... |
|
bool | invert () |
Inverts this matrix and returns success or failure. More... |
|
void | transpose () |
Transposes this matrix by exchanging rows and columns. More... |
|
void | translate (T x, T y, T z) |
Adds a relative translation to the matrix (by components). More... |
|
void | translate (const Vector< Float32, 3 > &vector) |
Adds a relative translation to the matrix (by vector). More... |
|
void | translate (const Vector< Float64, 3 > &vector) |
Adds a relative translation to the matrix (by vector). More... |
|
void | set_translation (T dx, T dy, T dz) |
Stores an absolute translation in the matrix (by component). More... |
|
void | set_translation (const Vector< Float32, 3 > &vector) |
Stores an absolute translation in the matrix (by vector). More... |
|
void | set_translation (const Vector< Float64, 3 > &vector) |
Stores an absolute translation in the matrix (by vector). More... |
|
void | rotate (T xangle, T yangle, T zangle) |
Adds a relative rotation to the matrix (Euler angles, by component). More... |
|
void | rotate (const Vector< Float32, 3 > &angles) |
Adds a relative rotation to the matrix (Euler angles, by vector). More... |
|
void | rotate (const Vector< Float64, 3 > &angles) |
Adds a relative rotation to the matrix (Euler angles, by vector). More... |
|
void | set_rotation (T x_angle, T y_angle, T z_angle) |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by component). More... |
|
void | set_rotation (const Vector< Float32, 3 > &angles) |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by vector). More... |
|
void | set_rotation (const Vector< Float64, 3 > &angles) |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by vector). More... |
|
void | set_rotation (const Vector< Float32, 3 > &axis, Float64 angle) |
Stores an absolute rotation (by axis and angle). More... |
|
void | set_rotation (const Vector< Float64, 3 > &axis, Float64 angle) |
Stores an absolute rotation (by axis and angle). More... |
|
void | lookat (const Vector< Float32, 3 > &position, const Vector< Float32, 3 > &target, const Vector< Float32, 3 > &up) |
Sets a transformation matrix based on a given center, a reference point, and a direction. More... |
|
void | lookat (const Vector< Float64, 3 > &position, const Vector< Float64, 3 > &target, const Vector< Float64, 3 > &up) |
Sets a transformation matrix based on a given center, a reference point, and a direction. More... |
|
Static Public Member Functions | |
static Size | size () |
Constant size of the vector. More... |
|
static Size | max_size () |
Constant maximum size of the vector. More... |
|
Public Attributes | |
T | elements [ROW *COL] |
general case matrix elements. More... |
|
Static Public Attributes | |
static const Size | ROWS = ROW |
Constant number of rows of the matrix. More... |
|
static const Size | COLUMNS = COL |
Constant number of columns of the matrix. More... |
|
static const Size | SIZE = ROW*COL |
Constant size of the matrix. More... |
|
NxM-dimensional matrix class template of fixed dimensions.
This class template provides array-like storage for ROW
times COL
many values of a (arithmetic) type T
. Several functions and arithmetic operators support the work with matrices.
The template parameters have the following requirements:
+ - * / == != < > <= >= sqrt()
.An instantiation of the matrix class template is a model of the STL container concept. It provides random access to its elements and corresponding random access iterators.
Depending on the dimensions ROW
and COL
, the mi::math::Matrix class template offers element access through the conventional data members named xx
, xy
, xz
, xw
, yx
, yy
, ..., wx
, wy
, wz
, ww
. The first letter denotes the row, the second letter the column. The following example, which, for the sake of illustration, defines a transformation matrix with a factor two scaling transformation:
xx, xy, xz, xw, yx, yy, ..., wx, wy, wz, ww
.operator
[] accesses row vectors, which follows the interpretation of the matrix as a vector of row vectors in accordance with its underlying row-major memory layout.typedef Vector<T,ROW> mi::math::Matrix< T, ROW, COL >::Column_vector |
Associated column vector of dimension ROW
.
typedef const T* mi::math::Matrix< T, ROW, COL >::const_pointer |
Const pointer to element.
typedef const T& mi::math::Matrix< T, ROW, COL >::const_reference |
Const reference to element.
typedef Difference mi::math::Matrix< T, ROW, COL >::difference_type |
Difference type, signed.
typedef Matrix_struct<T,ROW,COL> mi::math::Matrix< T, ROW, COL >::Pod_type |
POD class corresponding to this matrix.
typedef T* mi::math::Matrix< T, ROW, COL >::pointer |
Mutable pointer to element.
typedef T& mi::math::Matrix< T, ROW, COL >::reference |
Mutable reference to element.
typedef Vector<T,COL> mi::math::Matrix< T, ROW, COL >::Row_vector |
Associated row vector of dimension COL
.
typedef Size mi::math::Matrix< T, ROW, COL >::size_type |
Size type, unsigned.
typedef Matrix_struct<T,ROW,COL> mi::math::Matrix< T, ROW, COL >::storage_type |
Storage class used by this matrix.
typedef T mi::math::Matrix< T, ROW, COL >::value_type |
Element type.
enum mi::math::Matrix::Transposed_copy_tag |
|
inline |
The default constructor leaves the vector elements uninitialized.
|
inline |
Constructor from underlying storage type.
|
inlineexplicit |
Constructor initializes all matrix elements to zero and the diagonal elements to diag
.
Examples are diag==0
to create the null matrix and diag==1
to create the unit matrix.
diag | value for diagonal elements. |
|
inline |
Constructor requires the mi::math::FROM_ITERATOR tag as first argument and initializes the matrix elements with the first ROW
times COL
elements from the sequence starting at the iterator p
.
Iterator
must be a model of an input iterator. The value type of Iterator
must be assignment compatible with the matrix elements type T
.
An example:
|
inlineexplicit |
Constructor initializes the matrix elements from an array
of dimension ROW
times COL
.
The value type T2
of the array
must be assignment compatible with the matrix elements type T
.
An example that initializes a 2x2 unit matrix from an array:
|
inlineexplicit |
Template constructor that allows explicit conversions from other matrices with assignment compatible element value type.
|
inline |
Constructor that initializes the matrix with the transpose matrix of other
.
|
inline |
Template constructor that initializes the matrix with the transpose matrix of other
that allows the explicit conversions from other matrices with assignment compatible element value type.
|
inlineexplicit |
Dedicated constructor, for ROW==1
only, that initializes matrix from one row vector v0
.
ROW == 1
|
inline |
Dedicated constructor, for ROW==2
only, that initializes matrix from two row vectors (v0,v1).
ROW == 2
|
inline |
Dedicated constructor, for ROW==3
only, that initializes matrix from three row vectors (v0,v1,v2).
ROW == 3
|
inline |
Dedicated constructor, for ROW==4
only, that initializes matrix from four row vectors (v0,v1,v2,v3).
ROW == 4
|
inline |
2-element constructor, must be a 1x2 or 2x1 matrix.
The elements are given in row-major order.
|
inline |
3-element constructor, must be a 1x3 or 3x1 matrix.
The elements are given in row-major order.
|
inline |
4-element constructor, must be a 1x4, 2x2, or 4x1 matrix.
The elements are given in row-major order.
|
inline |
6-element constructor, must be a 2x3 or 3x2 matrix.
The elements are given in row-major order.
|
inline |
8-element constructor, must be a 2x4 or 4x2 matrix.
The elements are given in row-major order.
|
inline |
9-element constructor, must be a 3x3 matrix.
The elements are given in row-major order.
|
inline |
12-element constructor, must be a 3x4 or 4x3 matrix.
The elements are given in row-major order.
|
inline |
16-element constructor, must be a 4x4 matrix.
The elements are given in row-major order.
|
inline |
Returns the pointer to the first matrix element.
|
inline |
Returns the pointer to the first matrix element.
|
inline |
Returns the determinant of the upper-left 3x3 sub-matrix.
ROW==3
or ROW==4
) and (COL==3
or COL==4
)
|
inline |
|
inline |
|
inline |
Accesses the i-th
matrix element, indexed in the order of the row-major memory layout.
0 <= i < ROW*COL
|
inline |
Accesses the (row
, col
)-th matrix element.
0 <= row < ROW
and 0 <= col < COL
|
inline |
Inverts this matrix and returns success or failure.
The matrix cannot be inverted if it is singular or if it is non-square.
|
inline |
Sets a transformation matrix based on a given center, a reference point, and a direction.
The transformation is computed such that position
is mapped to the origin, target
is mapped to the negative Z-axis, and the up
direction is mapped to the positive Y-axis.
|
inline |
Sets a transformation matrix based on a given center, a reference point, and a direction.
The transformation is computed such that the origin is mapped to position
, the negative Z-axis is mapped to the target
direction, and the positive Y-axis is mapped to the up
direction.
|
inlinestatic |
Constant maximum size of the vector.
|
inline |
Accesses the (row
,col
)-th matrix element.
0 <= row < ROW
and 0 <= col < COL
|
inline |
Accesses the (row
, col
)-th matrix element.
0 <= row < ROW
and 0 <= col < COL
|
inline |
Assignment.
|
inline |
Accesses the row-th
row vector, 0 <= row < ROW
.
|
inline |
Accesses the row-th
row vector, 0 <= row < ROW
.
|
inline |
Adds a relative rotation to the matrix (Euler angles, by component).
The rotation is given by XYZ Euler angles (in radians). The elements in the last column of the matrix remain unchanged.
|
inline |
Adds a relative rotation to the matrix (Euler angles, by vector).
The rotation is given by XYZ Euler angles (in radians). The elements in the last column of the matrix remain unchanged.
|
inline |
Adds a relative rotation to the matrix (Euler angles, by vector).
The rotation is given by XYZ Euler angles (in radians). The elements in the last column of the matrix remain unchanged.
|
inline |
Sets the i-th
matrix element to value
, indexed in the order of the row-major memory layout.
0 <= i < ROW*COL
|
inline |
Sets the i-th
matrix element to value
, indexed in the order of the row-major memory layout.
0 <= row < ROW
and 0 <= col < COL
|
inline |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by component).
The rotation is given by XYZ Euler angles (in radians). The other matrix elements remain unchanged.
|
inline |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by vector).
The rotation is given by XYZ Euler angles (in radians). The other matrix elements remain unchanged.
|
inline |
Stores an absolute rotation in the upper left 3x3 rotation matrix (Euler angles, by vector).
The rotation is given by XYZ Euler angles (in radians). The other matrix elements remain unchanged.
|
inline |
Stores an absolute rotation (by axis and angle).
The computed rotation matrix describes a rotation by the given angle (in radians) around the given axis. The other matrix elements are set to 0 and 1, respectively.
axis
is normalized
|
inline |
Stores an absolute rotation (by axis and angle).
The computed rotation matrix describes a rotation by the given angle (in radians) around the given axis. The other matrix elements are set to 0 and 1, respectively.
axis
is normalized
|
inline |
Stores an absolute translation in the matrix (by component).
The other matrix elements remain unchanged.
|
inline |
Stores an absolute translation in the matrix (by vector).
The other matrix elements remain unchanged.
|
inline |
Stores an absolute translation in the matrix (by vector).
The other matrix elements remain unchanged.
|
inlinestatic |
Constant size of the vector.
|
inline |
Adds a relative translation to the matrix (by components).
The other matrix elements remain unchanged.
|
inline |
Adds a relative translation to the matrix (by vector).
The other matrix elements remain unchanged.
|
inline |
Adds a relative translation to the matrix (by vector).
The other matrix elements remain unchanged.
|
inline |
Transposes this matrix by exchanging rows and columns.
COL
For transposing non-square matrices see the mi::math::transpose() function.
|
static |
Constant number of columns of the matrix.
|
inherited |
general case matrix elements.
|
static |
Constant number of rows of the matrix.
|
static |
Constant size of the matrix.