NVIDIA Iray: Math API nvidia_logo_transpbg.gif Up
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
mi::math::Matrix_struct< T, ROW, COL > Struct Template Reference

Storage class for a NxM-dimensional matrix class template of fixed dimensions. More...

+ Inheritance diagram for mi::math::Matrix_struct< T, ROW, COL >:

Public Attributes

elements [ROW *COL]
 general case matrix elements. More...
 

Detailed Description

template<typename T, Size ROW, Size COL>
struct mi::math::Matrix_struct< T, ROW, COL >

Storage class for a NxM-dimensional matrix class template of fixed dimensions.

Used as base class for the mi::math::Matrix class template.

Use the mi::math::Matrix template in your programs and this storage class only if you need a POD type, for example for parameter passing.

This class template provides array-like storage for ROW times COL many values of a (arithmetic) type T. It has specializations for ROW in [1,4] and COL in [1,4]. These specializations use data members named xx, xy, xz, etc., according to the dimensions. The first letter denotes the row, the second letter the column. These specializations provide users of the mi::math::Matrix class template with the conventional member access to matrix elements, such as in the following example, which, for the sake of illustration, defines a transformation matrix with a factor two scaling transformation:

mat.xx = 2.0;
mat.yy = 2.0;
mat.zz = 2.0;
mat.ww = 1.0;

This class template contains only the data and no member functions. The necessary access abstraction is encoded in the free function mi::math::matrix_base_ptr(), which is overloaded for the general case and the various specializations for the small dimensions. It returns a pointer to the first element.

Memory layout:
Matrices are stored in row-major order, which says that the memory layout of a 4x4 matrix will be sequentially in memory xx, xy, xz, xw, yx, yy, ..., wx, wy, wz, ww.
Note
The matrix interpretation as a transformation is done by mi::math::transform_point(const Matrix<T,4,4>&,const Vector<U,4>&) and related functions. The convention if vectors are row vectors and multiplied from the left with matrices, or column vectors and multiplied from the right with matrices, determines where the different parameters of a transformation are actually stored in the matrix.

Member Data Documentation

template<typename T, Size ROW, Size COL>
T mi::math::Matrix_struct< T, ROW, COL >::elements[ROW *COL]

general case matrix elements.