Ocean
Ocean::SquareMatrixT4< T > Class Template Reference

This class implements a 4x4 square matrix. More...

Inheritance diagram for Ocean::SquareMatrixT4< T >:

Public Types

typedef T Type
 Definition of the used data type. More...
 

Public Member Functions

 SquareMatrixT4 ()
 Creates a new SquareMatrixT4 object with undefined elements. More...
 
 SquareMatrixT4 (const SquareMatrixT4< T > &matrix)=default
 Copy constructor. More...
 
template<typename U >
 SquareMatrixT4 (const SquareMatrixT4< U > &matrix)
 Copy constructor for a matrix with difference element data type than T. More...
 
 SquareMatrixT4 (const bool setToIdentity)
 Creates a new SquareMatrixT4 object. More...
 
template<typename U >
 SquareMatrixT4 (const U *arrayValues)
 Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U. More...
 
 SquareMatrixT4 (const T *arrayValues)
 Creates a new SquareMatrixT4 object by an array of at least sixteen elements. More...
 
template<typename U >
 SquareMatrixT4 (const U *arrayValues, const bool valuesRowAligned)
 Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U. More...
 
 SquareMatrixT4 (const T *arrayValues, const bool valuesRowAligned)
 Creates a new SquareMatrixT4 object by an array of at least sixteen elements. More...
 
 SquareMatrixT4 (const HomogenousMatrixT4< T > &transformation)
 Creates a new SquareMatrixT4 object by given transformation matrix. More...
 
 SquareMatrixT4 (const SquareMatrixT3< T > &subMatrix)
 Creates a new SquareMatrixT4 object by given 3x3 sub matrix. More...
 
 SquareMatrixT4 (const VectorT4< T > &diagonal)
 Creates a new SquareMatrixT4 object by a given diagonal vector. More...
 
SquareMatrixT4< T > transposed () const
 Returns the transposed of this matrix. More...
 
void transpose ()
 Transposes the matrix. More...
 
SquareMatrixT4< T > inverted () const
 Returns the inverted matrix of this matrix. More...
 
bool invert ()
 Inverts this matrix in place. More...
 
bool invert (SquareMatrixT4< T > &invertedMatrix) const
 Inverts the matrix and returns the result. More...
 
determinant () const
 Returns the determinant of the matrix. More...
 
trace () const
 Returns the trace of the matrix which is the sum of the diagonal elements. More...
 
void toIdentity ()
 Sets the matrix to the identity matrix. More...
 
void toNull ()
 Sets the matrix to a zero matrix. More...
 
bool isNull () const
 Returns whether this matrix is a null matrix. More...
 
bool isIdentity () const
 Returns whether this matrix is the identity matrix. More...
 
bool isSingular () const
 Returns whether this matrix is singular (and thus cannot be inverted). More...
 
bool isSymmetric (const T epsilon=NumericT< T >::eps()) const
 Returns whether this matrix is symmetric. More...
 
bool isEqual (const SquareMatrixT4< T > &matrix, const T eps=NumericT< T >::eps()) const
 Returns whether two matrices are almost identical up to a specified epsilon. More...
 
bool eigenSystem (VectorT4< T > &eigenValues, SquareMatrixT4< T > &eigenVectors)
 Performs an eigen value analysis. More...
 
const T * data () const
 Returns a pointer to the internal values. More...
 
T * data ()
 Returns a pointer to the internal values. More...
 
template<typename U >
void copyElements (U *arrayValues) const
 Copies the elements of this matrix to an array with floating point values of type U. More...
 
void copyElements (T *arrayValues) const
 Copies the elements of this matrix to an array with floating point values. More...
 
SquareMatrixT4< T > & operator= (const SquareMatrixT4< T > &)=default
 Default assign operator. More...
 
bool operator== (const SquareMatrixT4< T > &matrix) const
 Returns whether two matrices are identical up to a small epsilon. More...
 
bool operator!= (const SquareMatrixT4< T > &matrix) const
 Returns whether two matrices are not identical up to a small epsilon. More...
 
SquareMatrixT4< T > operator+ (const SquareMatrixT4< T > &matrix) const
 Adds two matrices. More...
 
SquareMatrixT4< T > & operator+= (const SquareMatrixT4< T > &matrix)
 Adds and assigns two matrices. More...
 
SquareMatrixT4< T > operator- (const SquareMatrixT4< T > &matrix) const
 Subtracts two matrices. More...
 
SquareMatrixT4< T > & operator-= (const SquareMatrixT4< T > &matrix)
 Subtracts and assigns two matrices. More...
 
SquareMatrixT4< T > operator- () const
 Returns the negative matrix of this matrix (all matrix elements are multiplied by -1). More...
 
OCEAN_FORCE_INLINE SquareMatrixT4< T > operator* (const SquareMatrixT4< T > &matrix) const
 Multiplies two matrices. More...
 
OCEAN_FORCE_INLINE SquareMatrixT4< T > operator* (const HomogenousMatrixT4< T > &matrix) const
 Multiplies two matrices. More...
 
OCEAN_FORCE_INLINE SquareMatrixT4< T > & operator*= (const SquareMatrixT4< T > &matrix)
 Multiplies and assigns two matrices. More...
 
OCEAN_FORCE_INLINE SquareMatrixT4< T > & operator*= (const HomogenousMatrixT4< T > &matrix)
 Multiplies and assigns two matrices. More...
 
OCEAN_FORCE_INLINE VectorT3< T > operator* (const VectorT3< T > &vector) const
 Multiply operator for a 3D vector. More...
 
OCEAN_FORCE_INLINE VectorT4< T > operator* (const VectorT4< T > &vector) const
 Multiply operator for a 4D vector. More...
 
SquareMatrixT4< T > operator* (const T value) const
 Multiplies this matrix with a scalar value. More...
 
SquareMatrixT4< T > & operator*= (const T value)
 Multiplies and assigns this matrix with a scalar value. More...
 
operator[] (const unsigned int index) const
 Element operator. More...
 
T & operator[] (const unsigned int index)
 Element operator. More...
 
operator() (const unsigned int row, const unsigned int column) const
 Element operator. More...
 
T & operator() (const unsigned int row, const unsigned int column)
 Element operator. More...
 
operator() (const unsigned int index) const
 Element operator. More...
 
T & operator() (const unsigned int index)
 Element operator. More...
 
const T * operator() () const
 Access operator. More...
 
T * operator() ()
 Access operator. More...
 
size_t operator() (const SquareMatrixT4< T > &matrix) const
 Hash function. More...
 
OCEAN_FORCE_INLINE SquareMatrixT4< double > operator* (const SquareMatrixT4< double > &matrix) const
 
OCEAN_FORCE_INLINE SquareMatrixT4< float > operator* (const SquareMatrixT4< float > &matrix) const
 
OCEAN_FORCE_INLINE SquareMatrixT4< float > operator* (const SquareMatrixT4< float > &matrix) const
 
OCEAN_FORCE_INLINE VectorT4< double > operator* (const VectorT4< double > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< double > operator* (const VectorT4< double > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< double > operator* (const VectorT4< double > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< float > operator* (const VectorT4< float > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< float > operator* (const VectorT4< float > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< double > operator* (const VectorT4< double > &vector) const
 
OCEAN_FORCE_INLINE VectorT4< float > operator* (const VectorT4< float > &vector) const
 
void multiply (const SquareMatrixT4< double > &matrix, const VectorT4< double > *vectors, VectorT4< double > *results, const size_t number)
 
void multiply (const SquareMatrixT4< float > &matrix, const VectorT4< float > *vectors, VectorT4< float > *results, const size_t number)
 
void multiply (const SquareMatrixT4< double > &matrix, const VectorT4< double > *vectors, VectorT4< double > *results, const size_t number)
 
void multiply (const SquareMatrixT4< float > &matrix, const VectorT4< float > *vectors, VectorT4< float > *results, const size_t number)
 
void multiply (const SquareMatrixT4< double > &matrix, const VectorT4< double > *vectors, VectorT4< double > *results, const size_t number)
 
void multiply (const SquareMatrixT4< float > &matrix, const VectorT4< float > *vectors, VectorT4< float > *results, const size_t number)
 
std::vector< SquareMatrixT4< float > > matrices2matrices (const std::vector< SquareMatrixT4< float > > &matrices)
 
std::vector< SquareMatrixT4< double > > matrices2matrices (const std::vector< SquareMatrixT4< double > > &matrices)
 

Static Public Member Functions

static size_t elements ()
 Returns the number of elements this matrix has. More...
 
static void multiply (const SquareMatrixT4< T > &matrix, const VectorT4< T > *vectors, VectorT4< T > *results, const size_t number)
 Multiplies several 4D vectors with a given matrix. More...
 
static SquareMatrixT4< T > projectionMatrix (const T fovX, const T aspectRatio, const T nearDistance, const T farDistance)
 Creates a projection matrix defined by the horizontal field of view, the aspect ratio and the near and far clipping plane. More...
 
static SquareMatrixT4< T > projectionMatrix (const AnyCameraT< T > &anyCamera, const T nearDistance, const T farDistance)
 Creates a projection matrix defined by a camera profile of a pinhole camera and the near and far clipping plane. More...
 
static SquareMatrixT4< T > frustumMatrix (const T left, const T right, const T top, const T bottom, const T nearDistance, const T farDistance)
 Creates a projection matrix defined by an asymmetric viewing frustum. More...
 
static SquareMatrixT4< T > frustumMatrix (const T width, const T height, const HomogenousMatrixT4< T > &viewingMatrix, const T nearDistance, const T farDistance)
 Creates a project matrix defined by an asymmetric viewing frustum. More...
 
template<typename U >
static std::vector< SquareMatrixT4< T > > matrices2matrices (const std::vector< SquareMatrixT4< U > > &matrices)
 Converts matrices with specific data type to matrices with different data type. More...
 
template<typename U >
static std::vector< SquareMatrixT4< T > > matrices2matrices (const SquareMatrixT4< U > *matrices, const size_t size)
 Converts matrices with specific data type to matrices with different data type. More...
 

Protected Member Functions

void swapRows (const unsigned int row0, const unsigned int row1)
 Swaps two rows of this matrix. More...
 
void multiplyRow (const unsigned int row, const T scalar)
 Multiplies a row with a scalar value. More...
 
void addRows (const unsigned int targetRow, const unsigned int sourceRow, const T scalar)
 Multiplies elements from a specific row with a scalar and adds them to another row. More...
 

Protected Attributes

values [16]
 The sixteen values of the matrix. More...
 

Friends

template<typename U >
class SquareMatrixT4
 

Detailed Description

template<typename T>
class Ocean::SquareMatrixT4< T >

This class implements a 4x4 square matrix.

The values are stored in a column aligned order with indices:

| 0  4  8  12 |
| 1  5  9  13 |
| 2  6  10 14 |
| 3  7  11 15 |
Template Parameters
TData type of matrix elements
See also
SquareMatrix4, SquareMatrixF4, SquareMatrixD4.

Member Typedef Documentation

◆ Type

template<typename T >
typedef T Ocean::SquareMatrixT4< T >::Type

Definition of the used data type.

Constructor & Destructor Documentation

◆ SquareMatrixT4() [1/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4
inline

Creates a new SquareMatrixT4 object with undefined elements.

Beware: This matrix is neither a zero nor an entity matrix!

◆ SquareMatrixT4() [2/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const SquareMatrixT4< T > &  matrix)
default

Copy constructor.

Parameters
matrixThe matrix to copy

◆ SquareMatrixT4() [3/11]

template<typename T >
template<typename U >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const SquareMatrixT4< U > &  matrix)
inlineexplicit

Copy constructor for a matrix with difference element data type than T.

Parameters
matrixThe matrix to copy
Template Parameters
UThe element data type of the second matrix

◆ SquareMatrixT4() [4/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const bool  setToIdentity)
explicit

Creates a new SquareMatrixT4 object.

Parameters
setToIdentityDetermines whether a entity matrix will be created

◆ SquareMatrixT4() [5/11]

template<typename T >
template<typename U >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const U *  arrayValues)
explicit

Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U.

Parameters
arrayValuesThe sixteen matrix elements defining the new matrix, must be valid
Template Parameters
UThe floating point type of the given elements

◆ SquareMatrixT4() [6/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const T *  arrayValues)
explicit

Creates a new SquareMatrixT4 object by an array of at least sixteen elements.

Parameters
arrayValuesThe sixteen matrix elements defining the new matrix, must be valid

◆ SquareMatrixT4() [7/11]

template<typename T >
template<typename U >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const U *  arrayValues,
const bool  valuesRowAligned 
)

Creates a new SquareMatrixT4 object by an array of at least sixteen elements of float type U.

Parameters
arrayValuesThe sixteen matrix elements defining the new matrix, must be valid
valuesRowAlignedTrue, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order (which is the default case for this matrix)
Template Parameters
UThe floating point type of the given elements

◆ SquareMatrixT4() [8/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const T *  arrayValues,
const bool  valuesRowAligned 
)

Creates a new SquareMatrixT4 object by an array of at least sixteen elements.

Parameters
valuesRowAlignedTrue, if the given values are stored in a row aligned order; False, if the values are stored in a column aligned order (which is the default case for this matrix)
arrayValuesThe sixteen matrix elements defining the new matrix, must be valid

◆ SquareMatrixT4() [9/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const HomogenousMatrixT4< T > &  transformation)
explicit

Creates a new SquareMatrixT4 object by given transformation matrix.

Parameters
transformationThe transformation matrix to copy

◆ SquareMatrixT4() [10/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const SquareMatrixT3< T > &  subMatrix)
explicit

Creates a new SquareMatrixT4 object by given 3x3 sub matrix.

The lower and right elements of the 4x4 square matrix are set to zero.

Parameters
subMatrix3x3 subMatrix defining the upper left elements of the new matrix

◆ SquareMatrixT4() [11/11]

template<typename T >
Ocean::SquareMatrixT4< T >::SquareMatrixT4 ( const VectorT4< T > &  diagonal)
explicit

Creates a new SquareMatrixT4 object by a given diagonal vector.

Parameters
diagonalThe diagonal vector for the new matrix

Member Function Documentation

◆ addRows()

template<typename T >
void Ocean::SquareMatrixT4< T >::addRows ( const unsigned int  targetRow,
const unsigned int  sourceRow,
const T  scalar 
)
protected

Multiplies elements from a specific row with a scalar and adds them to another row.

Parameters
targetRowThe index of the target row, with range [0, 3]
sourceRowThe index of the source row, with range [0, 3]
scalarThe scalar to multiply the source elements with

◆ copyElements() [1/2]

template<typename T >
void Ocean::SquareMatrixT4< T >::copyElements ( T *  arrayValues) const

Copies the elements of this matrix to an array with floating point values.

Parameters
arrayValuesArray with floating point values receiving the elements of this matrix

◆ copyElements() [2/2]

template<typename T >
template<typename U >
void Ocean::SquareMatrixT4< T >::copyElements ( U *  arrayValues) const

Copies the elements of this matrix to an array with floating point values of type U.

Parameters
arrayValuesArray with 16 floating point values of type U receiving the elements of this matrix
Template Parameters
UFloating point type

◆ data() [1/2]

template<typename T >
T * Ocean::SquareMatrixT4< T >::data
inline

Returns a pointer to the internal values.

Returns
Pointer to the internal values

◆ data() [2/2]

template<typename T >
const T * Ocean::SquareMatrixT4< T >::data
inline

Returns a pointer to the internal values.

Returns
Pointer to the internal values

◆ determinant()

template<typename T >
T Ocean::SquareMatrixT4< T >::determinant

Returns the determinant of the matrix.

Returns
Matrix determinant

◆ eigenSystem()

template<typename T >
bool Ocean::SquareMatrixT4< T >::eigenSystem ( VectorT4< T > &  eigenValues,
SquareMatrixT4< T > &  eigenVectors 
)

Performs an eigen value analysis.

Parameters
eigenValuesVector holding the three eigen values
eigenVectorsMatrix holding the three corresponding eigen vectors
Returns
True, if succeeded
Computation of the characteristic polynomial

    [ a b c d ]
A = [ e f g h ]
    [ i j k l ]
    [ m n o p ]

            [ a-x   b    c    d  ]
A - x * E = [  e   f-x   g    h  ]
            [  i    j   k-x   l  ]
            [  m    n    o   p-x ]

Polynomial = Det|A - x * E| = 0
           = x^4 + (-a - f - k - p)x^3 + (-be + af - ci - gj + ak + fk - dm - hn - lo + ap + fp + kp)x^2
              + (cfi - bgi - cej + agj + bek - afk + dfm - bhm + dkm - clm - den + ahn + hkn - gln - dio - hjo + alo + flo + bep - afp + cip + gjp - akp - fkp)x
              + (dgjm - chjm - dfkm + bhkm + cflm - bglm)
              + (-dgin + chin + dekn - ahkn - celn + agln)
              + (dfio - bhio - dejo + ahjo + belo - aflo)
              + (-cfip + bgip + cejp - agjp - bekp + afkp)
           = a1x^4 + a2x^3 + a3x^2 + a4x + a5 = 0

◆ elements()

template<typename T >
size_t Ocean::SquareMatrixT4< T >::elements
inlinestatic

Returns the number of elements this matrix has.

Returns
The number of elements, always 16

◆ frustumMatrix() [1/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::frustumMatrix ( const T  left,
const T  right,
const T  top,
const T  bottom,
const T  nearDistance,
const T  farDistance 
)
static

Creates a projection matrix defined by an asymmetric viewing frustum.

The shape of the frustum is defined by the rectangle on the near plane.
Afterwards, the field of view is defined by the (positive) distance to the near clipping plane.
Followed by the (positive) far clipping plane to determine the entire frustum.

Parameters
leftPosition of the left border of the rectangle on the near plane
rightPosition of the right border of the rectangle on the near plane
topPosition of the top border of the rectangle on the near plane
bottomPosition of the bottom border of the rectangle on the near plane
nearDistancePositive distance to the near clipping plane
farDistancePositive distance to the far clipping plane
Returns
Specified frustum projection matrix
Creates the following frustum projection matrix:

 --------------------------------------------------
| 2n/(r-l)       0       (r+l)/(r-l)         0     |
|    0        2n/(t-b)   (t+b)/(t-b)         0     |
|    0           0      -(f+n)/(f-n)    -2fn/(f-n) |
|    0           0           -1              0     |
 --------------------------------------------------

◆ frustumMatrix() [2/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::frustumMatrix ( const T  width,
const T  height,
const HomogenousMatrixT4< T > &  viewingMatrix,
const T  nearDistance,
const T  farDistance 
)
static

Creates a project matrix defined by an asymmetric viewing frustum.

The shape of the frustum is defined by the rectangle on the near plane.
The viewing position is defined by the given view matrix while the near plane is expected to lie in the origin of the coordinate system.

Parameters
widthThe width of the near plane, with range (0, infinity)
heightThe height of the near plane, with range (0, infinity)
viewingMatrixViewing matrix transforming point defined in the camera coordinate system into points defined in the world coordinate system, must be invertible
nearDistancePositive distance to the near clipping plane, with range (0, infinity)
farDistancePositive distance to the far clipping plane, with range (nearDistance, infinity)
Returns
Specified frustum projection matrix

◆ invert() [1/2]

template<typename T >
bool Ocean::SquareMatrixT4< T >::invert

Inverts this matrix in place.

Returns
True, if the matrix is not singular and could be inverted
See also
inverted().

◆ invert() [2/2]

template<typename T >
bool Ocean::SquareMatrixT4< T >::invert ( SquareMatrixT4< T > &  invertedMatrix) const

Inverts the matrix and returns the result.

Parameters
invertedMatrixThe resulting inverted matrix
Returns
True, if the matrix is not singular and could be inverted
See also
inverted().

◆ inverted()

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::inverted

Returns the inverted matrix of this matrix.

This matrix must not be singular.
Beware: This function does not throw an exception if the matrix cannot be inverted.
Thus, ensure that the matrix is invertible before calling this function.
Even better: avoid the usage of this function and call invert() instead.
In case, this matrix is not invertible, this matrix will be returned instead.

Returns
The inverted matrix
See also
invert(), isSingular().

◆ isEqual()

template<typename T >
bool Ocean::SquareMatrixT4< T >::isEqual ( const SquareMatrixT4< T > &  matrix,
const T  eps = NumericT<T>::eps() 
) const
inline

Returns whether two matrices are almost identical up to a specified epsilon.

Parameters
matrixSecond matrix that will be checked
epsThe epsilon threshold to be used, with range [0, infinity)
Returns
True, if so

◆ isIdentity()

template<typename T >
bool Ocean::SquareMatrixT4< T >::isIdentity

Returns whether this matrix is the identity matrix.

Returns
True, if so

◆ isNull()

template<typename T >
bool Ocean::SquareMatrixT4< T >::isNull

Returns whether this matrix is a null matrix.

Returns
True, if so

◆ isSingular()

template<typename T >
bool Ocean::SquareMatrixT4< T >::isSingular
inline

Returns whether this matrix is singular (and thus cannot be inverted).

A matrix is singular if the determinant of a matrix is 0.

Returns
True, if so

◆ isSymmetric()

template<typename T >
bool Ocean::SquareMatrixT4< T >::isSymmetric ( const T  epsilon = NumericT<T>::eps()) const

Returns whether this matrix is symmetric.

Parameters
epsilonThe epsilon threshold to be used, with range [0, infinity)
Returns
True, if so

◆ matrices2matrices() [1/4]

template<typename T >
template<typename U >
std::vector< SquareMatrixT4< T > > Ocean::SquareMatrixT4< T >::matrices2matrices ( const SquareMatrixT4< U > *  matrices,
const size_t  size 
)
inlinestatic

Converts matrices with specific data type to matrices with different data type.

Parameters
matricesThe matrices to convert
sizeThe number of matrices to convert
Returns
The converted matrices
Template Parameters
UThe element data type of the matrices to convert

◆ matrices2matrices() [2/4]

std::vector< SquareMatrixT4< double > > Ocean::SquareMatrixT4< double >::matrices2matrices ( const std::vector< SquareMatrixT4< double > > &  matrices)
inline

◆ matrices2matrices() [3/4]

std::vector< SquareMatrixT4< float > > Ocean::SquareMatrixT4< float >::matrices2matrices ( const std::vector< SquareMatrixT4< float > > &  matrices)
inline

◆ matrices2matrices() [4/4]

template<typename T >
template<typename U >
std::vector< SquareMatrixT4< T > > Ocean::SquareMatrixT4< T >::matrices2matrices ( const std::vector< SquareMatrixT4< U > > &  matrices)
inlinestatic

Converts matrices with specific data type to matrices with different data type.

Parameters
matricesThe matrices to convert
Returns
The converted matrices
Template Parameters
UThe element data type of the matrices to convert

◆ multiply() [1/7]

void Ocean::SquareMatrixT4< double >::multiply ( const SquareMatrixT4< double > &  matrix,
const VectorT4< double > *  vectors,
VectorT4< double > *  results,
const size_t  number 
)
inline

◆ multiply() [2/7]

void Ocean::SquareMatrixT4< double >::multiply ( const SquareMatrixT4< double > &  matrix,
const VectorT4< double > *  vectors,
VectorT4< double > *  results,
const size_t  number 
)
inline

◆ multiply() [3/7]

void Ocean::SquareMatrixT4< double >::multiply ( const SquareMatrixT4< double > &  matrix,
const VectorT4< double > *  vectors,
VectorT4< double > *  results,
const size_t  number 
)
inline

◆ multiply() [4/7]

void Ocean::SquareMatrixT4< float >::multiply ( const SquareMatrixT4< float > &  matrix,
const VectorT4< float > *  vectors,
VectorT4< float > *  results,
const size_t  number 
)
inline

◆ multiply() [5/7]

void Ocean::SquareMatrixT4< float >::multiply ( const SquareMatrixT4< float > &  matrix,
const VectorT4< float > *  vectors,
VectorT4< float > *  results,
const size_t  number 
)
inline

◆ multiply() [6/7]

void Ocean::SquareMatrixT4< float >::multiply ( const SquareMatrixT4< float > &  matrix,
const VectorT4< float > *  vectors,
VectorT4< float > *  results,
const size_t  number 
)
inline

◆ multiply() [7/7]

template<typename T >
void Ocean::SquareMatrixT4< T >::multiply ( const SquareMatrixT4< T > &  matrix,
const VectorT4< T > *  vectors,
VectorT4< T > *  results,
const size_t  number 
)
static

Multiplies several 4D vectors with a given matrix.

Parameters
matrixThe matrix to be used for multiplication, may be nullptr if number is 0
vectorsThe input vectors that will be multiplied, may be nullptr if number is 0
resultsThe resulting output (multiplied/transformed) vectors, with same number as the provided input vectors
numberThe number of provided vectors (input and output), with range [0, infinity)

◆ multiplyRow()

template<typename T >
void Ocean::SquareMatrixT4< T >::multiplyRow ( const unsigned int  row,
const T  scalar 
)
protected

Multiplies a row with a scalar value.

Parameters
rowThe index of the row to multiply, with range [0, 3]
scalarThe scalar to multiply

◆ operator!=()

template<typename T >
bool Ocean::SquareMatrixT4< T >::operator!= ( const SquareMatrixT4< T > &  matrix) const
inline

Returns whether two matrices are not identical up to a small epsilon.

Parameters
matrixRight operand
Returns
True, if so

◆ operator()() [1/7]

template<typename T >
T * Ocean::SquareMatrixT4< T >::operator()
inline

Access operator.

Returns
Pointer to the internal values

◆ operator()() [2/7]

template<typename T >
const T * Ocean::SquareMatrixT4< T >::operator()
inline

Access operator.

Returns
Pointer to the internal values

◆ operator()() [3/7]

template<typename T >
size_t Ocean::SquareMatrixT4< T >::operator() ( const SquareMatrixT4< T > &  matrix) const
inline

Hash function.

Parameters
matrixThe matrix for which the hash value will be determined
Returns
The resulting hash value

◆ operator()() [4/7]

template<typename T >
T & Ocean::SquareMatrixT4< T >::operator() ( const unsigned int  index)
inline

Element operator.

Beware: No range check will be done!

Parameters
indexThe index of the element to return [0, 15]
Returns
Specified element

◆ operator()() [5/7]

template<typename T >
T Ocean::SquareMatrixT4< T >::operator() ( const unsigned int  index) const
inline

Element operator.

Beware: No range check will be done!

Parameters
indexThe index of the element to return [0, 15]
Returns
Specified element

◆ operator()() [6/7]

template<typename T >
T & Ocean::SquareMatrixT4< T >::operator() ( const unsigned int  row,
const unsigned int  column 
)
inline

Element operator.

Beware: No range check will be done!

Parameters
rowThe row of the element to return [0, 3]
columnThe column of the element to return [0, 3]
Returns
Specified element

◆ operator()() [7/7]

template<typename T >
T Ocean::SquareMatrixT4< T >::operator() ( const unsigned int  row,
const unsigned int  column 
) const
inline

Element operator.

Beware: No range check will be done!

Parameters
rowThe row of the element to return [0, 3]
columnThe column of the element to return [0, 3]
Returns
Specified element

◆ operator*() [1/15]

template<typename T >
OCEAN_FORCE_INLINE SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator* ( const HomogenousMatrixT4< T > &  matrix) const

Multiplies two matrices.

Parameters
matrixRight operand
Returns
Product matrix

◆ operator*() [2/15]

OCEAN_FORCE_INLINE SquareMatrixT4< double > Ocean::SquareMatrixT4< double >::operator* ( const SquareMatrixT4< double > &  matrix) const

◆ operator*() [3/15]

OCEAN_FORCE_INLINE SquareMatrixT4< float > Ocean::SquareMatrixT4< float >::operator* ( const SquareMatrixT4< float > &  matrix) const

◆ operator*() [4/15]

OCEAN_FORCE_INLINE SquareMatrixT4< float > Ocean::SquareMatrixT4< float >::operator* ( const SquareMatrixT4< float > &  matrix) const

◆ operator*() [5/15]

template<typename T >
OCEAN_FORCE_INLINE SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator* ( const SquareMatrixT4< T > &  matrix) const

Multiplies two matrices.

Parameters
matrixRight operand
Returns
Product matrix

◆ operator*() [6/15]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator* ( const T  value) const

Multiplies this matrix with a scalar value.

Parameters
valueRight operand
Returns
Resulting matrix

◆ operator*() [7/15]

template<typename T >
OCEAN_FORCE_INLINE VectorT3< T > Ocean::SquareMatrixT4< T >::operator* ( const VectorT3< T > &  vector) const

Multiply operator for a 3D vector.

The 3D vector is interpreted as a 4D vector with fourth component equal to 1.
The final result will be de-homogenizated to provide a 3D vector result.
Beware the dot product of the last row with the vector must not be zero!

Parameters
vectorRight operand
Returns
Resulting 3D vector

◆ operator*() [8/15]

OCEAN_FORCE_INLINE VectorT4< double > Ocean::SquareMatrixT4< double >::operator* ( const VectorT4< double > &  vector) const

◆ operator*() [9/15]

OCEAN_FORCE_INLINE VectorT4< double > Ocean::SquareMatrixT4< double >::operator* ( const VectorT4< double > &  vector) const

◆ operator*() [10/15]

OCEAN_FORCE_INLINE VectorT4< double > Ocean::SquareMatrixT4< double >::operator* ( const VectorT4< double > &  vector) const

◆ operator*() [11/15]

OCEAN_FORCE_INLINE VectorT4< double > Ocean::SquareMatrixT4< double >::operator* ( const VectorT4< double > &  vector) const

◆ operator*() [12/15]

OCEAN_FORCE_INLINE VectorT4< float > Ocean::SquareMatrixT4< float >::operator* ( const VectorT4< float > &  vector) const

◆ operator*() [13/15]

OCEAN_FORCE_INLINE VectorT4< float > Ocean::SquareMatrixT4< float >::operator* ( const VectorT4< float > &  vector) const

◆ operator*() [14/15]

OCEAN_FORCE_INLINE VectorT4< float > Ocean::SquareMatrixT4< float >::operator* ( const VectorT4< float > &  vector) const

◆ operator*() [15/15]

template<typename T >
OCEAN_FORCE_INLINE VectorT4< T > Ocean::SquareMatrixT4< T >::operator* ( const VectorT4< T > &  vector) const

Multiply operator for a 4D vector.

Parameters
vectorRight operand
Returns
Resulting 4D vector

◆ operator*=() [1/3]

template<typename T >
SquareMatrixT4< T > & Ocean::SquareMatrixT4< T >::operator*= ( const HomogenousMatrixT4< T > &  matrix)
inline

Multiplies and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator*=() [2/3]

template<typename T >
SquareMatrixT4< T > & Ocean::SquareMatrixT4< T >::operator*= ( const SquareMatrixT4< T > &  matrix)
inline

Multiplies and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator*=() [3/3]

template<typename T >
SquareMatrixT4< T > & Ocean::SquareMatrixT4< T >::operator*= ( const T  value)

Multiplies and assigns this matrix with a scalar value.

Parameters
valueright operand
Returns
Reference to this object

◆ operator+()

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator+ ( const SquareMatrixT4< T > &  matrix) const

Adds two matrices.

Parameters
matrixRight operand
Returns
Sum matrix

◆ operator+=()

template<typename T >
SquareMatrixT4< T > & Ocean::SquareMatrixT4< T >::operator+= ( const SquareMatrixT4< T > &  matrix)

Adds and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator-() [1/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator-
inline

Returns the negative matrix of this matrix (all matrix elements are multiplied by -1).

Returns
Resulting negative matrix

◆ operator-() [2/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::operator- ( const SquareMatrixT4< T > &  matrix) const

Subtracts two matrices.

Parameters
matrixRight operand
Returns
Difference matrix

◆ operator-=()

template<typename T >
SquareMatrixT4< T > & Ocean::SquareMatrixT4< T >::operator-= ( const SquareMatrixT4< T > &  matrix)

Subtracts and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator=()

template<typename T >
SquareMatrixT4<T>& Ocean::SquareMatrixT4< T >::operator= ( const SquareMatrixT4< T > &  )
default

Default assign operator.

Returns
Reference to this object

◆ operator==()

template<typename T >
bool Ocean::SquareMatrixT4< T >::operator== ( const SquareMatrixT4< T > &  matrix) const

Returns whether two matrices are identical up to a small epsilon.

Parameters
matrixRight operand
Returns
True, if so

◆ operator[]() [1/2]

template<typename T >
T & Ocean::SquareMatrixT4< T >::operator[] ( const unsigned int  index)
inline

Element operator.

Beware: No range check will be done!

Parameters
indexThe index of the element to return [0, 15]
Returns
Specified element

◆ operator[]() [2/2]

template<typename T >
T Ocean::SquareMatrixT4< T >::operator[] ( const unsigned int  index) const
inline

Element operator.

Beware: No range check will be done!

Parameters
indexThe index of the element to return [0, 15]
Returns
Specified element

◆ projectionMatrix() [1/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::projectionMatrix ( const AnyCameraT< T > &  anyCamera,
const T  nearDistance,
const T  farDistance 
)
static

Creates a projection matrix defined by a camera profile of a pinhole camera and the near and far clipping plane.

Parameters
anyCameraThe camera profile of a pinhole camera, without distortion parameters, must be valid
nearDistancePositive distance to the near clipping plane
farDistancePositive distance to the far clipping lane
Returns
Specified projection matrix

◆ projectionMatrix() [2/2]

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::projectionMatrix ( const T  fovX,
const T  aspectRatio,
const T  nearDistance,
const T  farDistance 
)
static

Creates a projection matrix defined by the horizontal field of view, the aspect ratio and the near and far clipping plane.

Parameters
fovXHorizontal field of view, in radian and a range of [0, Pi]
aspectRatioView aspect ratio which is width divided by the height of the projection window
nearDistancePositive distance to the near clipping plane
farDistancePositive distance to the far clipping lane
Returns
Specified projection matrix

◆ swapRows()

template<typename T >
void Ocean::SquareMatrixT4< T >::swapRows ( const unsigned int  row0,
const unsigned int  row1 
)
protected

Swaps two rows of this matrix.

Parameters
row0The index of the first row ,with range [0, 3]
row1The index of the second row, with range [0, 3]

◆ toIdentity()

template<typename T >
void Ocean::SquareMatrixT4< T >::toIdentity
inline

Sets the matrix to the identity matrix.

◆ toNull()

template<typename T >
void Ocean::SquareMatrixT4< T >::toNull
inline

Sets the matrix to a zero matrix.

See also
isNull();

◆ trace()

template<typename T >
T Ocean::SquareMatrixT4< T >::trace

Returns the trace of the matrix which is the sum of the diagonal elements.

Returns
Trace of the matrix

◆ transpose()

template<typename T >
void Ocean::SquareMatrixT4< T >::transpose

Transposes the matrix.

◆ transposed()

template<typename T >
SquareMatrixT4< T > Ocean::SquareMatrixT4< T >::transposed

Returns the transposed of this matrix.

Returns
Transposed matrix

Friends And Related Function Documentation

◆ SquareMatrixT4

template<typename T >
template<typename U >
friend class SquareMatrixT4
friend

Field Documentation

◆ values

template<typename T >
T Ocean::SquareMatrixT4< T >::values[16]
protected

The sixteen values of the matrix.


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