Ocean
Ocean::SquareMatrixT3< T > Class Template Reference

This class implements a 3x3 square matrix. More...

Inheritance diagram for Ocean::SquareMatrixT3< T >:

Public Types

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

Public Member Functions

 SquareMatrixT3 ()
 Creates a new SquareMatrixT3 object with undefined elements. More...
 
 SquareMatrixT3 (const SquareMatrixT3< T > &matrix)=default
 Copy constructor. More...
 
template<typename U >
 SquareMatrixT3 (const SquareMatrixT3< U > &matrix)
 Copy constructor for a matrix with difference element data type than T. More...
 
 SquareMatrixT3 (const bool setToIdentity)
 Creates a new SquareMatrixT3 object. More...
 
 SquareMatrixT3 (const EulerT< T > &euler)
 Creates a new SquareMatrixT3 rotation matrix by a given Euler rotation. More...
 
 SquareMatrixT3 (const RotationT< T > &rotation)
 Creates a new 3x3 matrix object by a given angle-axis rotation. More...
 
 SquareMatrixT3 (const QuaternionT< T > &quaternion)
 Creates a new 3x3 matrix object by a given quaternion rotation. More...
 
 SquareMatrixT3 (const VectorT3< T > &xAxis, const VectorT3< T > &yAxis, const VectorT3< T > &zAxis)
 Creates a new SquareMatrixT3 object by three axes. More...
 
 SquareMatrixT3 (const VectorT3< T > &diagonal)
 Creates a new SquareMatrixT3 object by a given diagonal vector. More...
 
template<typename U >
 SquareMatrixT3 (const U *arrayValues)
 Creates a new SquareMatrixT3 object by nine elements of float type U. More...
 
 SquareMatrixT3 (const T *arrayValues)
 Creates a new SquareMatrixT3 object by nine elements. More...
 
template<typename U >
 SquareMatrixT3 (const U *arrayValues, const bool valuesRowAligned)
 Creates a new SquareMatrixT3 object by nine elements. More...
 
 SquareMatrixT3 (const T *arrayValues, const bool valuesRowAligned)
 Creates a new SquareMatrixT3 object by nine elements. More...
 
 SquareMatrixT3 (const HomogenousMatrixT4< T > &transformation)
 Creates a 3x3 rotation matrix by a given 4x4 homogeneous transformation. More...
 
 SquareMatrixT3 (const SquareMatrixT4< T > &transformation)
 Creates a 3x3 square matrix by a given 4x4 square transformation. More...
 
 SquareMatrixT3 (const T &m00, const T &m10, const T &m20, const T &m01, const T &m11, const T &m21, const T &m02, const T &m12, const T &m22)
 Creates a 3x3 rotation matrix by 9 given matrix elements. More...
 
SquareMatrixT3< T > transposed () const
 Returns the transposed of this matrix. More...
 
void transpose ()
 Transposes the matrix. More...
 
SquareMatrixT3< T > inverted () const
 Returns the inverted matrix of this matrix. More...
 
bool invert ()
 Inverts this matrix in place. More...
 
bool invert (SquareMatrixT3< T > &invertedMatrix) const
 Inverts the matrix and returns the result as parameter. 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 isIdentity () const
 Returns whether this matrix is an identity matrix. More...
 
bool isNull () const
 Returns whether this matrix is a zero matrix. More...
 
bool isSingular () const
 Returns whether this matrix is singular (and thus cannot be inverted). More...
 
bool isSimilarity () const
 Returns true if this matrix is a similarity transformation. More...
 
bool isAffine () const
 Returns true if this matrix is a affine transformation. More...
 
bool isHomography () const
 Returns true if this matrix is perspective transform/homography. More...
 
bool isOrthonormal (const T epsilon=NumericT< T >::eps()) const
 Returns whether this matrix is an orthonormal matrix. More...
 
bool isSymmetric (const T epsilon=NumericT< T >::eps()) const
 Returns whether this matrix is symmetric. More...
 
bool isEqual (const SquareMatrixT3< T > &matrix, const T eps=NumericT< T >::eps()) const
 Returns whether two matrices are almost identical up to a specified epsilon. More...
 
VectorT3< T > xAxis () const
 Returns the x axis which is the first column of the matrix. More...
 
VectorT3< T > yAxis () const
 Returns the y axis which is the middle column of the matrix. More...
 
VectorT3< T > zAxis () const
 Returns the z axis which is the last column of the matrix. More...
 
SquareMatrixT3< T > orthonormalMatrix () const
 Returns the orthonormal matrix of this matrix by scaling the x-axis and adjusting y- and z-axis. More...
 
bool eigenValues (T *eigenValues) const
 Determines the eigen values of this matrix. More...
 
bool eigenSystem (T *eigenValues, VectorT3< T > *eigenVectors) const
 Performs an eigen value analysis. More...
 
VectorT3< T > diagonal () const
 Returns a 3d vector with values of the matrix diagonal. More...
 
bool solve (const VectorT3< T > &b, VectorT3< T > &x) const
 Solve a simple 3x3 system of linear equations: Ax = b Beware: The system of linear equations is assumed to be fully determined. More...
 
absSum () const
 Calculates the sum of absolute value of elements. More...
 
sum () const
 Calculates the sum of elements. 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 bool valuesRowAligned=false) const
 Copies the elements of this matrix to an array with floating point values of type U. More...
 
void copyElements (T *arrayValues, const bool valuesRowAligned=false) const
 Copies the elements of this matrix to an array with floating point values of type T. More...
 
bool multiply (const VectorT2< T > &vector, VectorT2< T > &result) const
 Multiplies a 2D vector with this matrix (from the right). More...
 
SquareMatrixT3< T > transposedMultiply (const SquareMatrixT3< T > &right) const
 Multiplies this transposed matrix with a second matrix. More...
 
SquareMatrixT3< T > & operator= (const SquareMatrixT3< T > &)=default
 Default copy assignment operator. More...
 
bool operator== (const SquareMatrixT3< T > &matrix) const
 Returns whether two matrices are identical up to a small epsilon. More...
 
bool operator!= (const SquareMatrixT3< T > &matrix) const
 Returns whether two matrices are not identical up to a small epsilon. More...
 
SquareMatrixT3< T > operator+ (const SquareMatrixT3< T > &matrix) const
 Adds two matrices. More...
 
SquareMatrixT3< T > & operator+= (const SquareMatrixT3< T > &matrix)
 Adds and assigns two matrices. More...
 
SquareMatrixT3< T > operator- (const SquareMatrixT3< T > &matrix) const
 Subtracts two matrices. More...
 
SquareMatrixT3< T > & operator-= (const SquareMatrixT3< T > &matrix)
 Subtracts and assigns two matrices. More...
 
SquareMatrixT3< T > operator- () const
 Returns the negative matrix of this matrix (all matrix elements are multiplied by -1). More...
 
OCEAN_FORCE_INLINE SquareMatrixT3< T > operator* (const SquareMatrixT3< T > &matrix) const
 Multiplies two matrices. More...
 
OCEAN_FORCE_INLINE SquareMatrixT3< T > & operator*= (const SquareMatrixT3< T > &matrix)
 Multiplies and assigns two matrices. More...
 
OCEAN_FORCE_INLINE VectorT2< T > operator* (const VectorT2< T > &vector) const
 Multiply operator for a 2D vector. More...
 
OCEAN_FORCE_INLINE VectorT3< T > operator* (const VectorT3< T > &vector) const
 Multiply operator for a 3D vector. More...
 
OCEAN_FORCE_INLINE SquareMatrixT3< T > operator* (const T value) const
 Multiplies this matrix with a scalar value. More...
 
SquareMatrixT3< 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 SquareMatrixT3< T > &matrix) const
 Hash function. More...
 
OCEAN_FORCE_INLINE VectorT3< double > operator* (const VectorT3< double > &vector) const
 
OCEAN_FORCE_INLINE VectorT3< float > operator* (const VectorT3< float > &vector) const
 
void multiply (const SquareMatrixT3< float > &matrix, const VectorT3< float > *vectors, VectorT3< float > *results, const size_t number)
 
std::vector< SquareMatrixT3< float > > matrices2matrices (const std::vector< SquareMatrixT3< float > > &matrices)
 
std::vector< SquareMatrixT3< double > > matrices2matrices (const std::vector< SquareMatrixT3< double > > &matrices)
 
template<typename U >
std::vector< SquareMatrixT3< T > > matrices2matrices (const SquareMatrixT3< U > *matrices, const size_t size)
 

Static Public Member Functions

static SquareMatrixT3< T > skewSymmetricMatrix (const VectorT3< T > &vector)
 Creates a skew symmetric 3x3 matrix for a specific vector. More...
 
static size_t elements ()
 Returns the number of elements this matrix has. More...
 
static void multiply (const SquareMatrixT3< T > &matrix, const VectorT2< T > *vectors, VectorT2< T > *results, const size_t number)
 Multiplies several 2D vectors with a given 3x3 matrix. More...
 
static void multiply (const SquareMatrixT3< T > &matrix, const VectorT3< T > *vectors, VectorT3< T > *results, const size_t number)
 Multiplies several 3D vectors with a given 3x3 matrix. More...
 
template<typename U >
static SquareMatricesT3< T > matrices2matrices (const SquareMatricesT3< U > &matrices)
 Converts matrices with specific data type to matrices with different data type. More...
 
template<typename U >
static SquareMatricesT3< T > matrices2matrices (const SquareMatrixT3< U > *matrices, const size_t size)
 Converts matrices with specific data type to matrices with different data type. More...
 

Protected Attributes

values_ [9]
 The nine values of the matrix. More...
 

Friends

template<typename U >
class SquareMatrixT3
 

Detailed Description

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

This class implements a 3x3 square matrix.

The matrix can be applied as e.g., rotation matrix for 3D vectors or can represent a Homography and so on.
The values are stored in a column aligned order with indices:

| 0 3 6 |
| 1 4 7 |
| 2 5 8 |
Template Parameters
TData type of matrix elements
See also
SquareMatrix3, SquareMatrixF3, SquareMatrixD3, Rotation, Euler, Quaternion, ExponentialMap.

Member Typedef Documentation

◆ Type

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

Definition of the used data type.

Constructor & Destructor Documentation

◆ SquareMatrixT3() [1/16]

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

Creates a new SquareMatrixT3 object with undefined elements.

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

◆ SquareMatrixT3() [2/16]

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

Copy constructor.

Parameters
matrixThe matrix to copy

◆ SquareMatrixT3() [3/16]

template<typename T >
template<typename U >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const SquareMatrixT3< 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

◆ SquareMatrixT3() [4/16]

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

Creates a new SquareMatrixT3 object.

Parameters
setToIdentityDetermines whether a entity matrix will be created, otherwise the matrix is initialized with zeros

◆ SquareMatrixT3() [5/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const EulerT< T > &  euler)
explicit

Creates a new SquareMatrixT3 rotation matrix by a given Euler rotation.

Parameters
eulerEuler rotation to create a rotation matrix from, must be valid

Rotation matrix around x-axis R(x): [ 1 0 0 ] [ 0 cos -sin ] [ 0 sin cos ]

Rotation matrix around y-axis R(y): [ cos 0 sin ] [ 0 1 0 ] [ -sin 0 cos ]

Rotation matrix around z-axis R(z): [ cos -sin 0 ] [ sin cos 0 ] [ 0 0 1 ]

Combined rotation matrix for R(y)R(x)R(z) [ cy cz + sx sy sz cz sx sy - cy sz cx sy ] [ cx sz cx cz -sx ] [ -cz sy + cy sx sz cy cz sx + sy sz cx cy ]

◆ SquareMatrixT3() [6/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const RotationT< T > &  rotation)
explicit

Creates a new 3x3 matrix object by a given angle-axis rotation.

Parameters
rotationThe angle-axis rotation to create a matrix from, must be valid

◆ SquareMatrixT3() [7/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const QuaternionT< T > &  quaternion)
explicit

Creates a new 3x3 matrix object by a given quaternion rotation.

Parameters
quaternionThe quaternion rotation to create a matrix from, must be valid

◆ SquareMatrixT3() [8/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const VectorT3< T > &  xAxis,
const VectorT3< T > &  yAxis,
const VectorT3< T > &  zAxis 
)

Creates a new SquareMatrixT3 object by three axes.

Parameters
xAxisFirst column of the matrix
yAxisMiddle column of the matrix
zAxisLast column of the matrix

◆ SquareMatrixT3() [9/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const VectorT3< T > &  diagonal)
explicit

Creates a new SquareMatrixT3 object by a given diagonal vector.

Parameters
diagonalThe diagonal vector for the new matrix

◆ SquareMatrixT3() [10/16]

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

Creates a new SquareMatrixT3 object by nine elements of float type U.

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

◆ SquareMatrixT3() [11/16]

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

Creates a new SquareMatrixT3 object by nine elements.

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

◆ SquareMatrixT3() [12/16]

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

Creates a new SquareMatrixT3 object by nine elements.

Parameters
arrayValuesThe nine 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

◆ SquareMatrixT3() [13/16]

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

Creates a new SquareMatrixT3 object by nine elements.

Parameters
arrayValuesThe nine 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)

◆ SquareMatrixT3() [14/16]

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

Creates a 3x3 rotation matrix by a given 4x4 homogeneous transformation.

Parameters
transformationThe transformation to create a 3x3 rotation matrix from

◆ SquareMatrixT3() [15/16]

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

Creates a 3x3 square matrix by a given 4x4 square transformation.

Parameters
transformationThe transformation to create a 3x3 square matrix from

◆ SquareMatrixT3() [16/16]

template<typename T >
Ocean::SquareMatrixT3< T >::SquareMatrixT3 ( const T &  m00,
const T &  m10,
const T &  m20,
const T &  m01,
const T &  m11,
const T &  m21,
const T &  m02,
const T &  m12,
const T &  m22 
)
explicit

Creates a 3x3 rotation matrix by 9 given matrix elements.

Parameters
m00Element of the first row and first column
m10Element of the second row and first column
m20Element of the third row and first column
m01Element of the first row and second column
m11Element of the second row and second column
m21Element of the third row and second column
m02Element of the first row and third column
m12Element of the second row and third column
m22Element of the third row and third column

Member Function Documentation

◆ absSum()

template<typename T >
T Ocean::SquareMatrixT3< T >::absSum
inline

Calculates the sum of absolute value of elements.

Returns
Sum of absolute value of elements

◆ copyElements() [1/2]

template<typename T >
void Ocean::SquareMatrixT3< T >::copyElements ( T *  arrayValues,
const bool  valuesRowAligned = false 
) const

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

Parameters
arrayValuesArray with 9 floating point values of type T receiving the elements of this matrix
valuesRowAlignedTrue, if the target values are stored in a row aligned order; False, if the target values are stored in a column aligned order

◆ copyElements() [2/2]

template<typename T >
template<typename U >
void Ocean::SquareMatrixT3< T >::copyElements ( U *  arrayValues,
const bool  valuesRowAligned = false 
) const

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

Parameters
arrayValuesArray with 9 floating point values of type U receiving the elements of this matrix
valuesRowAlignedTrue, if the target values are stored in a row aligned order; False, if the target values are stored in a column aligned order
Template Parameters
UFloating point type

◆ data() [1/2]

template<typename T >
T * Ocean::SquareMatrixT3< 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::SquareMatrixT3< T >::data
inline

Returns a pointer to the internal values.

Returns
Pointer to the internal values

◆ determinant()

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

Returns the determinant of the matrix.

Returns
Matrix determinant

◆ diagonal()

template<typename T >
VectorT3< T > Ocean::SquareMatrixT3< T >::diagonal

Returns a 3d vector with values of the matrix diagonal.

Returns
Vector with diagonal values

◆ eigenSystem()

template<typename T >
bool Ocean::SquareMatrixT3< T >::eigenSystem ( T *  eigenValues,
VectorT3< T > *  eigenVectors 
) const

Performs an eigen value analysis.

Parameters
eigenValuesThe three resulting eigen values, sorted: the highest first
eigenVectorsThe three corresponding eigen vectors
Returns
True, if succeeded

Computation of the characteristic polynomial

    [ a b c ]
A = [ d e f ]
    [ g h i ]

            [ a-x   b    c  ]
A - x * E = [  d   e-x   f  ]
            [  g    h   i-x ]

Polynomial = Det|A - x * E| = 0
           = (a - x) * (e - x)          * (i - x) + bfg + cdh - g * (e - x) * c  - h * f * (a - x)  - (i - x) * d * b
           = (ae - a * x - e * x + x^2) * (i - x) + bfg + cdh - g * (ec - c * x) - h * (fa - f * x) - d * (ib - x * b)
           = aei - ae * x - ai * x + a * x^2 - ei * x + e * x^2 + i * x^2 - x^3 + bfg + cdh - gec + gc * x - hfa + hf * x - dib + db * x
           = -x^3 + (a + e + i) * x^2 + (-ae - ai - ei + gc + hf + db) * x + aei + bfg + cdh - gec - hfa - dib
           = x^3 - (a + e + i) * x^2 - (-ae - ai - ei + gc + hf + db) * x - aei - bfg - cdh + gec + hfa + dib
           = a1x^3 + a2x^2 + a3x + a4 = 0
Determination of the eigen vectors (vx, vy, vz):
            [ a-x   b    c  ]   [ vx ]
A - x * E = [  d   e-x   f  ] * [ vy ] = 0
            [  g    h   i-x ]   [ vz ]
We can apply the cross product to find a vector that is perpendicular to the two top rows of the matrix A - x * E

◆ eigenValues()

template<typename T >
bool Ocean::SquareMatrixT3< T >::eigenValues ( T *  eigenValues) const

Determines the eigen values of this matrix.

Parameters
eigenValuesThe three resulting eigen values, sorted: the highest first
Returns
True, if succeeded

Computation of the characteristic polynomial


    [ a b c ]
A = [ d e f ]
    [ g h i ]

            [ a-x   b    c  ]
A - x * E = [  d   e-x   f  ]
            [  g    h   i-x ]

Polynomial = Det|A - x * E| = 0
           = (a - x) * (e - x)          * (i - x) + bfg + cdh - g * (e - x) * c  - h * f * (a - x)  - (i - x) * d * b
           = (ae - a * x - e * x + x^2) * (i - x) + bfg + cdh - g * (ec - c * x) - h * (fa - f * x) - d * (ib - x * b)
           = aei - ae * x - ai * x + a * x^2 - ei * x + e * x^2 + i * x^2 - x^3 + bfg + cdh - gec + gc * x - hfa + hf * x - dib + db * x
           = -x^3 + (a + e + i) * x^2 + (-ae - ai - ei + gc + hf + db) * x + aei + bfg + cdh - gec - hfa - dib
           = x^3 - (a + e + i) * x^2 - (-ae - ai - ei + gc + hf + db) * x - aei - bfg - cdh + gec + hfa + dib
           = a1x^3 + a2x^2 + a3x + a4 = 0

◆ elements()

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

Returns the number of elements this matrix has.

Returns
The number of elements, always 9

◆ invert() [1/2]

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

Inverts this matrix in place.

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

◆ invert() [2/2]

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

Inverts the matrix and returns the result as parameter.

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

◆ inverted()

template<typename T >
SquareMatrixT3< T > Ocean::SquareMatrixT3< 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().

◆ isAffine()

template<typename T >
bool Ocean::SquareMatrixT3< T >::isAffine
inline

Returns true if this matrix is a affine transformation.

In order to be considered affine, the matrix mustn't be singular and the last row must be equivalent to [0 0 1].

Returns
True, if this matrix is an affine transformation, otherwise false

◆ isEqual()

template<typename T >
bool Ocean::SquareMatrixT3< T >::isEqual ( const SquareMatrixT3< 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

◆ isHomography()

template<typename T >
bool Ocean::SquareMatrixT3< T >::isHomography
inline

Returns true if this matrix is perspective transform/homography.

In order to be considered a homography, the matrix mustn't be singular and the bottom-right matrix element must be nonzero.

Returns
True, if this matrix is a homography, otherwise false

◆ isIdentity()

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

Returns whether this matrix is an identity matrix.

Returns
True, if so
See also
toIdentity().

◆ isNull()

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

Returns whether this matrix is a zero matrix.

Returns
True, if so
See also
toNull().

◆ isOrthonormal()

template<typename T >
bool Ocean::SquareMatrixT3< T >::isOrthonormal ( const T  epsilon = NumericT<T>::eps()) const

Returns whether this matrix is an orthonormal matrix.

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

◆ isSimilarity()

template<typename T >
bool Ocean::SquareMatrixT3< T >::isSimilarity
inline

Returns true if this matrix is a similarity transformation.

A similarity transformation has four degrees of freedom and contains a rotation, a scale, and a 2D translation and is not singular.
The 3x3 matrix representing the similarity transformation has the following layout:

| a  -b  tx |
| b   a  ty |
| 0   0   1 |
Returns
True, if this matrix is a similarity transformation, otherwise false

◆ isSingular()

template<typename T >
bool Ocean::SquareMatrixT3< 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::SquareMatrixT3< T >::isSymmetric ( const T  epsilon = NumericT<T>::eps()) const
inline

Returns whether this matrix is symmetric.

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

◆ matrices2matrices() [1/5]

template<typename T >
template<typename U >
SquareMatricesT3< T > Ocean::SquareMatrixT3< T >::matrices2matrices ( const SquareMatricesT3< 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

◆ matrices2matrices() [2/5]

template<typename T >
template<typename U >
static SquareMatricesT3<T> Ocean::SquareMatrixT3< T >::matrices2matrices ( const SquareMatrixT3< 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() [3/5]

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

◆ matrices2matrices() [4/5]

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

◆ matrices2matrices() [5/5]

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

◆ multiply() [1/4]

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

◆ multiply() [2/4]

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

Multiplies several 2D vectors with a given 3x3 matrix.

Each 2D vector is interpreted as a 3D vector with third component equal to 1.
The final result will be de-homogenized to provide a 2D vector result.

Parameters
matrixThe matrix to be used for multiplication
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)

◆ multiply() [3/4]

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

Multiplies several 3D vectors with a given 3x3 matrix.

Parameters
matrixThe matrix to be used for multiplication
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)

◆ multiply() [4/4]

template<typename T >
bool Ocean::SquareMatrixT3< T >::multiply ( const VectorT2< T > &  vector,
VectorT2< T > &  result 
) const
inline

Multiplies a 2D vector with this matrix (from the right).

The 2D vector is interpreted as a 3D vector with third component equal to 1.
This function is equivalent with the corresponding multiplication operator but returns False if the dot product between the augmented vector and the last row is zero.
The multiplication result will be de-homogenized to provide a 2D vector result, if possible.
Actually this function does:

Parameters
vectorThe vector to be multiplied/transformed
resultThe de-homogenized resulting 2D vector, if this function succeeds
Returns
True, if the dot product between the augmented vector and the last row is non-zero; False, otherwise
See also
operator*(const VectorT2<T>& vector).

| x' | | 0 3 6 | | x | | y' | = | 1 4 7 | * | y | | 1 | | 2 5 8 | | 1 |

◆ operator!=()

template<typename T >
bool Ocean::SquareMatrixT3< T >::operator!= ( const SquareMatrixT3< 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::SquareMatrixT3< T >::operator()
inline

Access operator.

Returns
Pointer to the internal values

◆ operator()() [2/7]

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

Access operator.

Returns
Pointer to the internal values

◆ operator()() [3/7]

template<typename T >
size_t Ocean::SquareMatrixT3< T >::operator() ( const SquareMatrixT3< 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::SquareMatrixT3< 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, 8]
Returns
Specified element

◆ operator()() [5/7]

template<typename T >
T Ocean::SquareMatrixT3< 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, 8]
Returns
Specified element

◆ operator()() [6/7]

template<typename T >
T & Ocean::SquareMatrixT3< 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, 2]
columnThe column of the element to return [0, 2]
Returns
Specified element

◆ operator()() [7/7]

template<typename T >
T Ocean::SquareMatrixT3< 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, 2]
columnThe column of the element to return [0, 2]
Returns
Specified element

◆ operator*() [1/6]

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

Multiplies two matrices.

Parameters
matrixRight operand
Returns
Product matrix

◆ operator*() [2/6]

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

Multiplies this matrix with a scalar value.

Parameters
valueRight operand
Returns
Resulting matrix

◆ operator*() [3/6]

template<typename T >
OCEAN_FORCE_INLINE VectorT2< T > Ocean::SquareMatrixT3< T >::operator* ( const VectorT2< T > &  vector) const

Multiply operator for a 2D vector.

The 2D vector is interpreted as a 3D vector with third component equal to 1.
The final result will be de-homogenized to provide a 2D vector result.
Beware the dot product between the last row and the (augmented) vector must not be zero!

Parameters
vectorRight operand, vector to be multiplied from the right
Returns
Resulting 2D vector
See also
multiply().

| x' | | 0 3 6 | | x | | y' | = | 1 4 7 | * | y | | 1 | | 2 5 8 | | 1 |

◆ operator*() [4/6]

OCEAN_FORCE_INLINE VectorT3< double > Ocean::SquareMatrixT3< double >::operator* ( const VectorT3< double > &  vector) const

◆ operator*() [5/6]

OCEAN_FORCE_INLINE VectorT3< float > Ocean::SquareMatrixT3< float >::operator* ( const VectorT3< float > &  vector) const

◆ operator*() [6/6]

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

Multiply operator for a 3D vector.

Parameters
vectorRight operand
Returns
Resulting 3D vector

◆ operator*=() [1/2]

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

Multiplies and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator*=() [2/2]

template<typename T >
SquareMatrixT3< T > & Ocean::SquareMatrixT3< 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 >
SquareMatrixT3< T > Ocean::SquareMatrixT3< T >::operator+ ( const SquareMatrixT3< T > &  matrix) const

Adds two matrices.

Parameters
matrixRight operand
Returns
Sum matrix

◆ operator+=()

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

Adds and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator-() [1/2]

template<typename T >
SquareMatrixT3< T > Ocean::SquareMatrixT3< 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 >
SquareMatrixT3< T > Ocean::SquareMatrixT3< T >::operator- ( const SquareMatrixT3< T > &  matrix) const

Subtracts two matrices.

Parameters
matrixRight operand
Returns
Difference matrix

◆ operator-=()

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

Subtracts and assigns two matrices.

Parameters
matrixRight operand
Returns
Reference to this object

◆ operator=()

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

Default copy assignment operator.

Returns
Reference to this object

◆ operator==()

template<typename T >
bool Ocean::SquareMatrixT3< T >::operator== ( const SquareMatrixT3< 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::SquareMatrixT3< 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, 8]
Returns
Specified element

◆ operator[]() [2/2]

template<typename T >
T Ocean::SquareMatrixT3< 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, 8]
Returns
Specified element

◆ orthonormalMatrix()

template<typename T >
SquareMatrixT3< T > Ocean::SquareMatrixT3< T >::orthonormalMatrix

Returns the orthonormal matrix of this matrix by scaling the x-axis and adjusting y- and z-axis.

This matrix must not be singular.

Returns
An orthonormal version of this matrix

◆ skewSymmetricMatrix()

template<typename T >
SquareMatrixT3< T > Ocean::SquareMatrixT3< T >::skewSymmetricMatrix ( const VectorT3< T > &  vector)
inlinestatic

Creates a skew symmetric 3x3 matrix for a specific vector.

The skew symmetric matrix allows to calculate the cross product of the specified vector with a second vector by a matrix multiplication.
That means: skewSymmetricMatrix(vectorA) * vectorB == vectorA.cross(vectorB)
The final matrix has the following form for a vector (v0, v1, v2):

|  0   -v2    v1 |
| v2     0   -v0 |
| -v1   v0     0 |
Parameters
vectorThe vector for which the skew symmetric matrix will be created
Returns
Resulting matrix

◆ solve()

template<typename T >
bool Ocean::SquareMatrixT3< T >::solve ( const VectorT3< T > &  b,
VectorT3< T > &  x 
) const
inline

Solve a simple 3x3 system of linear equations: Ax = b Beware: The system of linear equations is assumed to be fully determined.

Parameters
bThe right-hand side vector
xThe resulting solution vector
Returns
True, if the solution is valid, otherwise false
See also
invert(), inverted().

◆ sum()

template<typename T >
T Ocean::SquareMatrixT3< T >::sum
inline

Calculates the sum of elements.

Returns
Sum of elements

◆ toIdentity()

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

Sets the matrix to the identity matrix.

See also
isIdentity().

◆ toNull()

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

Sets the matrix to a zero matrix.

See also
isNull();

◆ trace()

template<typename T >
T Ocean::SquareMatrixT3< 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::SquareMatrixT3< T >::transpose

Transposes the matrix.

◆ transposed()

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

Returns the transposed of this matrix.

Returns
Transposed matrix

◆ transposedMultiply()

template<typename T >
SquareMatrixT3< T > Ocean::SquareMatrixT3< T >::transposedMultiply ( const SquareMatrixT3< T > &  right) const

Multiplies this transposed matrix with a second matrix.

Actually, the following matrix will be returned: (*this).transposed() * right.

Parameters
rightMatrix to multiply
Returns
Matrix product

◆ xAxis()

template<typename T >
VectorT3< T > Ocean::SquareMatrixT3< T >::xAxis

Returns the x axis which is the first column of the matrix.

Returns
Vector with the first column

◆ yAxis()

template<typename T >
VectorT3< T > Ocean::SquareMatrixT3< T >::yAxis

Returns the y axis which is the middle column of the matrix.

Returns
Vector with the middle column

◆ zAxis()

template<typename T >
VectorT3< T > Ocean::SquareMatrixT3< T >::zAxis

Returns the z axis which is the last column of the matrix.

Returns
Vector with the last column

Friends And Related Function Documentation

◆ SquareMatrixT3

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

Field Documentation

◆ values_

template<typename T >
T Ocean::SquareMatrixT3< T >::values_[9]
protected

The nine values of the matrix.


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