PURE API 0.5
PR00F's Ultimate Rendering Engine full documentation
Loading...
Searching...
No Matches
PureMatrix Class Reference

Pure basic 4x4 matrix class. More...

Detailed Description

Pure basic 4x4 matrix class.

For 3D transformations, descendant PureTransformMatrix class is recommended.

Definition at line 32 of file PureMatrix.h.

#include <PureMatrix.h>

+ Inheritance diagram for PureMatrix:

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 TPureFloatget () 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 TPureFloatgetTransposed ()
 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 TPureFloatgetInverse ()
 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.
 
PureMatrixoperator= (const PureMatrix &cm)
 Assignment operator.
 
PureMatrix operator+ (const PureMatrix &cm) const
 Addition operator.
 
PureMatrixoperator+= (const PureMatrix &cm)
 Addition assignment operator.
 
PureMatrix operator- (const PureMatrix &cm) const
 Subtraction operator.
 
PureMatrixoperator-= (const PureMatrix &cm)
 Subtraction assignment operator.
 
PureMatrix operator* (const PureMatrix &cm) const
 Multiplication by matrix operator.
 
PureMatrixoperator*= (const PureMatrix &cm)
 Multiplication assignment operator.
 
PureMatrix operator* (const TPureFloat &scalar) const
 Multiplication by scalar operator.
 
PureMatrixoperator*= (const TPureFloat &scalar)
 Multiplication assignment operator.
 
PureVector operator* (const PureVector &vec) const
 Multiplication by vector operator.
 
TPureFloatoperator() (const TPureByte &row, const TPureByte &col)
 Access element operator operator.
 
const TPureFloatoperator() (const TPureByte &row, const TPureByte &col) const
 Access element operator operator.
 

Static Public Member Functions

static const PureMatrixgetZero ()
 Gets a constant zero matrix.
 
static const PureMatrixgetIdentity ()
 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.
 

Constructor & Destructor Documentation

◆ PureMatrix() [1/3]

PureMatrix::PureMatrix ( )

Creates an identity matrix.

Definition at line 39 of file PureMatrix.cpp.

◆ PureMatrix() [2/3]

PureMatrix::PureMatrix ( const PureMatrix & cm)

Definition at line 45 of file PureMatrix.cpp.

◆ PureMatrix() [3/3]

PureMatrix::PureMatrix ( const TPURE_NOTABLE_MATRICES & nm)
explicit

Creates the requested matrix.

Definition at line 54 of file PureMatrix.cpp.

◆ ~PureMatrix()

PureMatrix::~PureMatrix ( )
virtual

Definition at line 64 of file PureMatrix.cpp.

Member Function Documentation

◆ correctIndices()

TPureBool PureMatrix::correctIndices ( TPureByte row,
TPureByte col )
staticprivate

Are the given row and column indices correct?

Returns
True if the given indices are both correct.

Definition at line 509 of file PureMatrix.cpp.

◆ get() [1/2]

const TPureFloat * PureMatrix::get ( ) const

Returns the matrix array as is.

Definition at line 94 of file PureMatrix.cpp.

◆ get() [2/2]

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.

◆ getDeterminant()

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.

◆ getIdentity()

const PureMatrix & PureMatrix::getIdentity ( )
static

Gets a constant identity matrix.

Definition at line 30 of file PureMatrix.cpp.

◆ getInverse()

const TPureFloat * PureMatrix::getInverse ( )

Returns the matrix array in its inverted form without actually modifying the matrix.

See more about matrix invert at invert().

Returns
Pointer to matrix array in its inverted form if inversion is successful, NULL otherwise.

Definition at line 246 of file PureMatrix.cpp.

◆ getTransposed()

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.

◆ getZero()

const PureMatrix & PureMatrix::getZero ( )
static

Gets a constant zero matrix.

Definition at line 21 of file PureMatrix.cpp.

◆ ind()

TPureByte PureMatrix::ind ( TPureByte row,
TPureByte col )
staticprivate

Returns index of cell in given row and column.

Definition at line 518 of file PureMatrix.cpp.

◆ invert()

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).

Returns
True if inversion is successful, false otherwise.

Definition at line 235 of file PureMatrix.cpp.

◆ invertArray()

TPureBool PureMatrix::invertArray ( TPureFloat arr[],
TPureByte rows,
TPureByte cols )
staticprivate

Treats the given array as a matrix and inverts it.

No effect on input array if matrix is not invertible.

Returns
True if inversion is successful, false otherwise.

Definition at line 555 of file PureMatrix.cpp.

◆ isIdentity()

TPureBool PureMatrix::isIdentity ( ) const

Is it an identity matrix?

Definition at line 125 of file PureMatrix.cpp.

◆ isInvertible()

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.

Returns
True if the matrix is invertible, false otherwise.

Definition at line 220 of file PureMatrix.cpp.

◆ isZero()

TPureBool PureMatrix::isZero ( ) const

Is it a zero matrix?

Definition at line 103 of file PureMatrix.cpp.

◆ operator!=()

TPureBool PureMatrix::operator!= ( const PureMatrix & cm) const

Not equals to operator.

Definition at line 265 of file PureMatrix.cpp.

◆ operator()() [1/2]

TPureFloat & PureMatrix::operator() ( const TPureByte & row,
const TPureByte & col )

Access element operator operator.

Definition at line 417 of file PureMatrix.cpp.

◆ operator()() [2/2]

const TPureFloat & PureMatrix::operator() ( const TPureByte & row,
const TPureByte & col ) const

Access element operator operator.

Definition at line 430 of file PureMatrix.cpp.

◆ operator*() [1/3]

PureMatrix PureMatrix::operator* ( const PureMatrix & cm) const

Multiplication by matrix operator.

Definition at line 334 of file PureMatrix.cpp.

◆ operator*() [2/3]

PureVector PureMatrix::operator* ( const PureVector & vec) const

Multiplication by vector operator.

Definition at line 400 of file PureMatrix.cpp.

◆ operator*() [3/3]

PureMatrix PureMatrix::operator* ( const TPureFloat & scalar) const

Multiplication by scalar operator.

Definition at line 375 of file PureMatrix.cpp.

◆ operator*=() [1/2]

PureMatrix & PureMatrix::operator*= ( const PureMatrix & cm)

Multiplication assignment operator.

Definition at line 354 of file PureMatrix.cpp.

◆ operator*=() [2/2]

PureMatrix & PureMatrix::operator*= ( const TPureFloat & scalar)

Multiplication assignment operator.

Definition at line 388 of file PureMatrix.cpp.

◆ operator+()

PureMatrix PureMatrix::operator+ ( const PureMatrix & cm) const

Addition operator.

Definition at line 284 of file PureMatrix.cpp.

◆ operator+=()

PureMatrix & PureMatrix::operator+= ( const PureMatrix & cm)

Addition assignment operator.

Definition at line 297 of file PureMatrix.cpp.

◆ operator-()

PureMatrix PureMatrix::operator- ( const PureMatrix & cm) const

Subtraction operator.

Definition at line 309 of file PureMatrix.cpp.

◆ operator-=()

PureMatrix & PureMatrix::operator-= ( const PureMatrix & cm)

Subtraction assignment operator.

Definition at line 322 of file PureMatrix.cpp.

◆ operator=()

PureMatrix & PureMatrix::operator= ( const PureMatrix & cm)

Assignment operator.

Definition at line 274 of file PureMatrix.cpp.

◆ operator==()

TPureBool PureMatrix::operator== ( const PureMatrix & cm) const

Equals to operator.

Definition at line 256 of file PureMatrix.cpp.

◆ Set()

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.

◆ SetIdentity()

void PureMatrix::SetIdentity ( )

Sets the matrix to identity matrix.

Definition at line 150 of file PureMatrix.cpp.

◆ SetZero()

void PureMatrix::SetZero ( )

Sets the matrix to zero matrix.

Definition at line 115 of file PureMatrix.cpp.

◆ Transpose()

void PureMatrix::Transpose ( )

Transposes the matrix.

Definition at line 163 of file PureMatrix.cpp.

◆ TransposeArray()

void PureMatrix::TransposeArray ( TPureFloat * arr,
TPureByte rows,
TPureByte cols )
staticprivate

Treats the given array as a matrix and transposes it.

Definition at line 527 of file PureMatrix.cpp.

Member Data Documentation

◆ mat

TPureFloat PureMatrix::mat[4][4]
protected

Values.

Definition at line 88 of file PureMatrix.h.

◆ matIdentity

PureMatrix PureMatrix::matIdentity
staticprivate

Static zero matrix.

Definition at line 91 of file PureMatrix.h.

◆ matZero

PureMatrix PureMatrix::matZero
staticprivate

Static identity matrix.

Definition at line 92 of file PureMatrix.h.

◆ tanspmat

TPureFloat PureMatrix::tanspmat[4][4]
private

Values when matrix is requested as transposed.

Definition at line 104 of file PureMatrix.h.


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