![]() |
PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
|
Pure basic 4x4 matrix class. More...
Pure basic 4x4 matrix class.
For 3D transformations, descendant PureTransformMatrix class is recommended.
Definition at line 32 of file PureMatrix.h.
#include <PureMatrix.h>
Public Member Functions | |
PureMatrix () | |
Creates an identity matrix. | |
PureMatrix (const PureMatrix &cm) | |
PureMatrix (const TPURE_NOTABLE_MATRICES &nm) | |
Creates the requested matrix. | |
virtual | ~PureMatrix () |
TPureFloat | get (TPureByte row, TPureByte col) const |
Gets the element at the given row and column. | |
void | Set (TPureByte row, TPureByte col, TPureFloat value) |
Sets the element at the given row and column. | |
const TPureFloat * | get () const |
Returns the matrix array as is. | |
TPureBool | isZero () const |
Is it a zero matrix? | |
void | SetZero () |
Sets the matrix to zero matrix. | |
TPureBool | isIdentity () const |
Is it an identity matrix? | |
void | SetIdentity () |
Sets the matrix to identity matrix. | |
void | Transpose () |
Transposes the matrix. | |
const TPureFloat * | getTransposed () |
Returns the matrix array in its transposed form without actually modifying the matrix. | |
TPureFloat | getDeterminant () const |
Returns the determinant of the matrix. | |
TPureBool | isInvertible () const |
Returns if the matrix is invertible. | |
TPureBool | invert () |
Inverts the matrix. | |
const TPureFloat * | getInverse () |
Returns the matrix array in its inverted form without actually modifying the matrix. | |
TPureBool | operator== (const PureMatrix &cm) const |
Equals to operator. | |
TPureBool | operator!= (const PureMatrix &cm) const |
Not equals to operator. | |
PureMatrix & | operator= (const PureMatrix &cm) |
Assignment operator. | |
PureMatrix | operator+ (const PureMatrix &cm) const |
Addition operator. | |
PureMatrix & | operator+= (const PureMatrix &cm) |
Addition assignment operator. | |
PureMatrix | operator- (const PureMatrix &cm) const |
Subtraction operator. | |
PureMatrix & | operator-= (const PureMatrix &cm) |
Subtraction assignment operator. | |
PureMatrix | operator* (const PureMatrix &cm) const |
Multiplication by matrix operator. | |
PureMatrix & | operator*= (const PureMatrix &cm) |
Multiplication assignment operator. | |
PureMatrix | operator* (const TPureFloat &scalar) const |
Multiplication by scalar operator. | |
PureMatrix & | operator*= (const TPureFloat &scalar) |
Multiplication assignment operator. | |
PureVector | operator* (const PureVector &vec) const |
Multiplication by vector operator. | |
TPureFloat & | operator() (const TPureByte &row, const TPureByte &col) |
Access element operator operator. | |
const TPureFloat & | operator() (const TPureByte &row, const TPureByte &col) const |
Access element operator operator. | |
Static Public Member Functions | |
static const PureMatrix & | getZero () |
Gets a constant zero matrix. | |
static const PureMatrix & | getIdentity () |
Gets a constant identity matrix. | |
Protected Attributes | |
TPureFloat | mat [4][4] |
Values. | |
Static Private Member Functions | |
static TPureBool | correctIndices (TPureByte row, TPureByte col) |
Are the given row and column indices correct? | |
static TPureByte | ind (TPureByte row, TPureByte col) |
Returns index of cell in given row and column. | |
static void | TransposeArray (TPureFloat *arr, TPureByte rows, TPureByte cols) |
Treats the given array as a matrix and transposes it. | |
static TPureBool | invertArray (TPureFloat arr[], TPureByte rows, TPureByte cols) |
Treats the given array as a matrix and inverts it. | |
Private Attributes | |
TPureFloat | tanspmat [4][4] |
Values when matrix is requested as transposed. | |
Static Private Attributes | |
static PureMatrix | matIdentity |
Static zero matrix. | |
static PureMatrix | matZero |
Static identity matrix. | |
PureMatrix::PureMatrix | ( | ) |
Creates an identity matrix.
Definition at line 39 of file PureMatrix.cpp.
PureMatrix::PureMatrix | ( | const PureMatrix & | cm | ) |
Definition at line 45 of file PureMatrix.cpp.
|
explicit |
Creates the requested matrix.
Definition at line 54 of file PureMatrix.cpp.
|
virtual |
Definition at line 64 of file PureMatrix.cpp.
Are the given row and column indices correct?
Definition at line 509 of file PureMatrix.cpp.
const TPureFloat * PureMatrix::get | ( | ) | const |
Returns the matrix array as is.
Definition at line 94 of file PureMatrix.cpp.
TPureFloat PureMatrix::get | ( | TPureByte | row, |
TPureByte | col ) const |
Gets the element at the given row and column.
Definition at line 73 of file PureMatrix.cpp.
TPureFloat PureMatrix::getDeterminant | ( | ) | const |
Returns the determinant of the matrix.
Determinant of the identity matrix is 1: det(I) = 1. Determinant of a matrix with any row or column having all elements equal to 0 is 0. Determinant of a transposed matrix equals to the determinant of the original matrix: det(transp(A)) = det(A). Determinant of an inverted matrix equals to the determinant of the original matrix: det(inverse(A)) = 1 / det(A).
Definition at line 187 of file PureMatrix.cpp.
|
static |
Gets a constant identity matrix.
Definition at line 30 of file PureMatrix.cpp.
const TPureFloat * PureMatrix::getInverse | ( | ) |
Returns the matrix array in its inverted form without actually modifying the matrix.
See more about matrix invert at invert().
Definition at line 246 of file PureMatrix.cpp.
const TPureFloat * PureMatrix::getTransposed | ( | ) |
Returns the matrix array in its transposed form without actually modifying the matrix.
Returns the matrix in its transposed form without actually modifying the matrix.
Definition at line 172 of file PureMatrix.cpp.
|
static |
Gets a constant zero matrix.
Definition at line 21 of file PureMatrix.cpp.
Returns index of cell in given row and column.
Definition at line 518 of file PureMatrix.cpp.
TPureBool PureMatrix::invert | ( | ) |
Inverts the matrix.
Has no effect if the matrix in not invertible (when it is singular alias degenerate). The inverse of a translation by (tx, ty, tz) is a translation by (-tx, -ty, -tz). The inverse of a rotation by n degrees is a rotation by -n degrees. The inverse of a scale by (sx, sy, sz) in the direction of the X-Y-Z axes is a scale by (1/sx, 1/sy, 1/sz).
Definition at line 235 of file PureMatrix.cpp.
|
staticprivate |
Treats the given array as a matrix and inverts it.
No effect on input array if matrix is not invertible.
Definition at line 555 of file PureMatrix.cpp.
TPureBool PureMatrix::isIdentity | ( | ) | const |
Is it an identity matrix?
Definition at line 125 of file PureMatrix.cpp.
TPureBool PureMatrix::isInvertible | ( | ) | const |
Returns if the matrix is invertible.
The matrix is invertible only if its determinant is non-zero. If determinant is zero, the matrix is not invertible, and then we call the matrix singular or degenerate.
Definition at line 220 of file PureMatrix.cpp.
TPureBool PureMatrix::isZero | ( | ) | const |
Is it a zero matrix?
Definition at line 103 of file PureMatrix.cpp.
TPureBool PureMatrix::operator!= | ( | const PureMatrix & | cm | ) | const |
Not equals to operator.
Definition at line 265 of file PureMatrix.cpp.
TPureFloat & PureMatrix::operator() | ( | const TPureByte & | row, |
const TPureByte & | col ) |
Access element operator operator.
Definition at line 417 of file PureMatrix.cpp.
const TPureFloat & PureMatrix::operator() | ( | const TPureByte & | row, |
const TPureByte & | col ) const |
Access element operator operator.
Definition at line 430 of file PureMatrix.cpp.
PureMatrix PureMatrix::operator* | ( | const PureMatrix & | cm | ) | const |
Multiplication by matrix operator.
Definition at line 334 of file PureMatrix.cpp.
PureVector PureMatrix::operator* | ( | const PureVector & | vec | ) | const |
Multiplication by vector operator.
Definition at line 400 of file PureMatrix.cpp.
PureMatrix PureMatrix::operator* | ( | const TPureFloat & | scalar | ) | const |
Multiplication by scalar operator.
Definition at line 375 of file PureMatrix.cpp.
PureMatrix & PureMatrix::operator*= | ( | const PureMatrix & | cm | ) |
Multiplication assignment operator.
Definition at line 354 of file PureMatrix.cpp.
PureMatrix & PureMatrix::operator*= | ( | const TPureFloat & | scalar | ) |
Multiplication assignment operator.
Definition at line 388 of file PureMatrix.cpp.
PureMatrix PureMatrix::operator+ | ( | const PureMatrix & | cm | ) | const |
Addition operator.
Definition at line 284 of file PureMatrix.cpp.
PureMatrix & PureMatrix::operator+= | ( | const PureMatrix & | cm | ) |
Addition assignment operator.
Definition at line 297 of file PureMatrix.cpp.
PureMatrix PureMatrix::operator- | ( | const PureMatrix & | cm | ) | const |
Subtraction operator.
Definition at line 309 of file PureMatrix.cpp.
PureMatrix & PureMatrix::operator-= | ( | const PureMatrix & | cm | ) |
Subtraction assignment operator.
Definition at line 322 of file PureMatrix.cpp.
PureMatrix & PureMatrix::operator= | ( | const PureMatrix & | cm | ) |
Assignment operator.
Definition at line 274 of file PureMatrix.cpp.
TPureBool PureMatrix::operator== | ( | const PureMatrix & | cm | ) | const |
Equals to operator.
Definition at line 256 of file PureMatrix.cpp.
void PureMatrix::Set | ( | TPureByte | row, |
TPureByte | col, | ||
TPureFloat | value ) |
Sets the element at the given row and column.
Definition at line 82 of file PureMatrix.cpp.
void PureMatrix::SetIdentity | ( | ) |
Sets the matrix to identity matrix.
Definition at line 150 of file PureMatrix.cpp.
void PureMatrix::SetZero | ( | ) |
Sets the matrix to zero matrix.
Definition at line 115 of file PureMatrix.cpp.
void PureMatrix::Transpose | ( | ) |
Transposes the matrix.
Definition at line 163 of file PureMatrix.cpp.
|
staticprivate |
Treats the given array as a matrix and transposes it.
Definition at line 527 of file PureMatrix.cpp.
|
protected |
Values.
Definition at line 88 of file PureMatrix.h.
|
staticprivate |
Static zero matrix.
Definition at line 91 of file PureMatrix.h.
|
staticprivate |
Static identity matrix.
Definition at line 92 of file PureMatrix.h.
|
private |
Values when matrix is requested as transposed.
Definition at line 104 of file PureMatrix.h.