ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cloudViewer::SquareMatrixTpl< Scalar > Class Template Reference

Square matrix. More...

#include <SquareMatrix.h>

Inheritance diagram for cloudViewer::SquareMatrixTpl< Scalar >:

Public Member Functions

 SquareMatrixTpl ()
 Default constructor. More...
 
 SquareMatrixTpl (unsigned size)
 Constructor with a given size. More...
 
 SquareMatrixTpl (const SquareMatrixTpl< double > &mat)
 Constructor from another double matrix. More...
 
 SquareMatrixTpl (const SquareMatrixTpl< float > &mat)
 Constructor from another float matrix. More...
 
 SquareMatrixTpl (const float M16f[], bool rotationOnly=false)
 "From OpenGl" constructor (float version) More...
 
 SquareMatrixTpl (const double M16d[], bool rotationOnly=false)
 "From OpenGl" constructor (double version) More...
 
virtual ~SquareMatrixTpl ()
 Default destructor. More...
 
 SquareMatrixTpl (const Eigen::Matrix< Scalar, 3, 3 > &mat)
 Copy Function. More...
 
 SquareMatrixTpl (const Eigen::Matrix< Scalar, 4, 4 > &mat)
 
SquareMatrixTploperator= (const Eigen::Matrix< Scalar, 3, 3 > &mat)
 Assignment Function. More...
 
SquareMatrixTploperator= (const Eigen::Matrix< Scalar, 4, 4 > &mat)
 
void toArray (Scalar data[])
 
unsigned size () const
 Returns matrix size. More...
 
bool isValid () const
 Returns matrix validity. More...
 
void invalidate ()
 Invalidates matrix. More...
 
Scalar * row (unsigned index)
 Returns pointer to matrix row. More...
 
void setValue (unsigned row, unsigned column, Scalar value)
 Sets a particular matrix value. More...
 
Scalar getValue (unsigned row, unsigned column) const
 Returns a particular matrix value. More...
 
SquareMatrixTploperator= (const SquareMatrixTpl &B)
 Matrix copy operator. More...
 
SquareMatrixTpl operator+ (const SquareMatrixTpl &B) const
 Addition. More...
 
const SquareMatrixTploperator+= (const SquareMatrixTpl &B)
 In-place addition. More...
 
SquareMatrixTpl operator- (const SquareMatrixTpl &B) const
 Subtraction. More...
 
const SquareMatrixTploperator-= (const SquareMatrixTpl &B)
 In-place subtraction. More...
 
SquareMatrixTpl operator* (const SquareMatrixTpl &B) const
 Multiplication (M = A*B) More...
 
Vector3Tpl< Scalar > operator* (const Vector3Tpl< Scalar > &V) const
 Multiplication by a vector. More...
 
const SquareMatrixTploperator*= (const SquareMatrixTpl &B)
 In-place multiplication. More...
 
void apply (const float vec[], float result[]) const
 Multiplication by a float vector, outputs a float vector. More...
 
void apply (const float vec[], double result[]) const
 Multiplication by a float vector, outputs a double vector. More...
 
void apply (const double vec[], double result[]) const
 Multiplication by a double vector. More...
 
void transpose ()
 In-place transpose. More...
 
SquareMatrixTpl transposed () const
 Returns the transposed version of this matrix. More...
 
void clear ()
 Sets all elements to 0. More...
 
SquareMatrixTpl inv () const
 Returns inverse (Gauss) More...
 
void print (FILE *fp=nullptr) const
 Prints out matrix to console or file. More...
 
void toIdentity ()
 Sets matrix to identity. More...
 
void scale (Scalar coef)
 Scales matrix (all elements are multiplied by the same coef.) More...
 
Scalar trace () const
 Returns trace. More...
 
double computeDet () const
 Returns determinant. More...
 
void initFromQuaternion (const float q[])
 Creates a rotation matrix from a quaternion (float version) More...
 
void initFromQuaternion (const double q[])
 Creates a rotation matrix from a quaternion (double version) More...
 
bool toQuaternion (double q[])
 Converts rotation matrix to quaternion. More...
 
Scalar deltaDeterminant (unsigned column, Scalar *Vec) const
 Returns Delta-determinant (see Kramer formula) More...
 
void toGlMatrix (float M16f[]) const
 Converts a 3*3 or 4*4 matrix to an OpenGL-style float matrix (float[16]) More...
 
void toGlMatrix (double M16d[]) const
 
bool svd (SquareMatrixTpl &S, SquareMatrixTpl &U, SquareMatrixTpl &V) const
 

Public Attributes

Scalar ** m_values = nullptr
 The matrix rows. More...
 

Detailed Description

template<typename Scalar>
class cloudViewer::SquareMatrixTpl< Scalar >

Square matrix.

Row-major ordered matrix (i.e. elements are accessed with 'values[row][column]')

Definition at line 25 of file SquareMatrix.h.

Constructor & Destructor Documentation

◆ SquareMatrixTpl() [1/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( )
inline

Default constructor.

Warning: invalid matrix.

Definition at line 30 of file SquareMatrix.h.

Referenced by cloudViewer::SquareMatrixTpl< Scalar >::inv().

◆ SquareMatrixTpl() [2/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( unsigned  size)
inline

Constructor with a given size.

Parameters
sizethe (square) matrix dimension

Definition at line 35 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ SquareMatrixTpl() [3/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const SquareMatrixTpl< double > &  mat)
inline

Constructor from another double matrix.

Parameters
matmatrix

Definition at line 40 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::getValue(), cloudViewer::SquareMatrixTpl< Scalar >::setValue(), and cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ SquareMatrixTpl() [4/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const SquareMatrixTpl< float > &  mat)
inline

Constructor from another float matrix.

Parameters
matmatrix

Definition at line 51 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::getValue(), cloudViewer::SquareMatrixTpl< Scalar >::setValue(), and cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ SquareMatrixTpl() [5/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const float  M16f[],
bool  rotationOnly = false 
)
inline

"From OpenGl" constructor (float version)

The matrix dimension is automatically set to 4. It can be forced to 3 (size_3 = true). In this case, only the rotation part will be 'imported'.

Parameters
M16fa table of 16 floats (OpenGL float transformation matrix)
rotationOnlyconsider only the roation part (3x3 matrix)

Definition at line 66 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values, and cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ SquareMatrixTpl() [6/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const double  M16d[],
bool  rotationOnly = false 
)
inline

"From OpenGl" constructor (double version)

The matrix dimension is automatically set to 4. It can be forced to 3 (size_3 = true). In this case, only the rotation part will be 'imported'.

Parameters
M16da table of 16 floats (OpenGL double transformation matrix)
rotationOnlyconsider only the roation part (3x3 matrix)

Definition at line 83 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values, and cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ ~SquareMatrixTpl()

template<typename Scalar >
virtual cloudViewer::SquareMatrixTpl< Scalar >::~SquareMatrixTpl ( )
inlinevirtual

Default destructor.

Definition at line 94 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::invalidate().

◆ SquareMatrixTpl() [7/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const Eigen::Matrix< Scalar, 3, 3 > &  mat)
inline

Copy Function.

Definition at line 97 of file SquareMatrix.h.

◆ SquareMatrixTpl() [8/8]

template<typename Scalar >
cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl ( const Eigen::Matrix< Scalar, 4, 4 > &  mat)
inline

Definition at line 100 of file SquareMatrix.h.

Member Function Documentation

◆ apply() [1/3]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::apply ( const double  vec[],
double  result[] 
) const
inline

Multiplication by a double vector.

Vec must have the same size as this matrix.

Parameters
vecinput vector
resultoutput vector (= M * vec)

Definition at line 294 of file SquareMatrix.h.

◆ apply() [2/3]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::apply ( const float  vec[],
double  result[] 
) const
inline

Multiplication by a float vector, outputs a double vector.

Vec must have the same size as this matrix.

Parameters
vecinput vector
resultoutput vector (= M * vec)

Definition at line 280 of file SquareMatrix.h.

◆ apply() [3/3]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::apply ( const float  vec[],
float  result[] 
) const
inline

Multiplication by a float vector, outputs a float vector.

Vec must have the same size as this matrix.

Parameters
vecinput vector
resultoutput vector (= M * vec)

Definition at line 266 of file SquareMatrix.h.

Referenced by cloudViewer::SquareMatrixTpl< Scalar >::operator*().

◆ clear()

◆ computeDet()

template<typename Scalar >
double cloudViewer::SquareMatrixTpl< Scalar >::computeDet ( ) const
inline

◆ deltaDeterminant()

template<typename Scalar >
Scalar cloudViewer::SquareMatrixTpl< Scalar >::deltaDeterminant ( unsigned  column,
Scalar *  Vec 
) const
inline

Returns Delta-determinant (see Kramer formula)

Definition at line 582 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::computeDet(), and cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ getValue()

◆ initFromQuaternion() [1/2]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::initFromQuaternion ( const double  q[])
inline

Creates a rotation matrix from a quaternion (double version)

Quaternion is composed of 4 values: an angle (cos(alpha/2)) and an axis (sin(alpha/2)*unit vector).

Parameters
qnormalized quaternion (w,x,y,z)

Definition at line 492 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ initFromQuaternion() [2/2]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::initFromQuaternion ( const float  q[])
inline

Creates a rotation matrix from a quaternion (float version)

Shortcut to double version of initFromQuaternion)

Parameters
qnormalized quaternion (4 float values)

Definition at line 480 of file SquareMatrix.h.

Referenced by GetPoseInformation(), and cloudViewer::RegistrationTools::RegistrationProcedure().

◆ inv()

template<typename Scalar >
SquareMatrixTpl cloudViewer::SquareMatrixTpl< Scalar >::inv ( ) const
inline

◆ invalidate()

◆ isValid()

◆ operator*() [1/2]

template<typename Scalar >
SquareMatrixTpl cloudViewer::SquareMatrixTpl< Scalar >::operator* ( const SquareMatrixTpl< Scalar > &  B) const
inline

Multiplication (M = A*B)

Definition at line 225 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::size().

◆ operator*() [2/2]

template<typename Scalar >
Vector3Tpl<Scalar> cloudViewer::SquareMatrixTpl< Scalar >::operator* ( const Vector3Tpl< Scalar > &  V) const
inline

Multiplication by a vector.

Definition at line 243 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::apply(), result, and Tuple3Tpl< Type >::u.

◆ operator*=()

template<typename Scalar >
const SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator*= ( const SquareMatrixTpl< Scalar > &  B)
inline

In-place multiplication.

Definition at line 255 of file SquareMatrix.h.

◆ operator+()

template<typename Scalar >
SquareMatrixTpl cloudViewer::SquareMatrixTpl< Scalar >::operator+ ( const SquareMatrixTpl< Scalar > &  B) const
inline

Addition.

Definition at line 187 of file SquareMatrix.h.

◆ operator+=()

template<typename Scalar >
const SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator+= ( const SquareMatrixTpl< Scalar > &  B)
inline

◆ operator-()

template<typename Scalar >
SquareMatrixTpl cloudViewer::SquareMatrixTpl< Scalar >::operator- ( const SquareMatrixTpl< Scalar > &  B) const
inline

Subtraction.

Definition at line 206 of file SquareMatrix.h.

◆ operator-=()

template<typename Scalar >
const SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator-= ( const SquareMatrixTpl< Scalar > &  B)
inline

◆ operator=() [1/3]

template<typename Scalar >
SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator= ( const Eigen::Matrix< Scalar, 3, 3 > &  mat)
inline

Assignment Function.

Definition at line 105 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ operator=() [2/3]

template<typename Scalar >
SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator= ( const Eigen::Matrix< Scalar, 4, 4 > &  mat)
inline

Definition at line 114 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ operator=() [3/3]

template<typename Scalar >
SquareMatrixTpl& cloudViewer::SquareMatrixTpl< Scalar >::operator= ( const SquareMatrixTpl< Scalar > &  B)
inline

◆ print()

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::print ( FILE *  fp = nullptr) const
inline

Prints out matrix to console or file.

Parameters
fpASCII FILE handle (or 0 to print to console)

Definition at line 435 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ row()

◆ scale()

◆ setValue()

◆ size()

◆ svd()

◆ toArray()

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::toArray ( Scalar  data[])
inline

Definition at line 123 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ toGlMatrix() [1/2]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::toGlMatrix ( double  M16d[]) const
inline

Converts a 3*3 or 4*4 matrix to an OpenGL-style double matrix (double[16])

Definition at line 620 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

◆ toGlMatrix() [2/2]

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::toGlMatrix ( float  M16f[]) const
inline

Converts a 3*3 or 4*4 matrix to an OpenGL-style float matrix (float[16])

Definition at line 601 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

Referenced by ccCompass::estimateStrain(), and GetPoseInformation().

◆ toIdentity()

◆ toQuaternion()

template<typename Scalar >
bool cloudViewer::SquareMatrixTpl< Scalar >::toQuaternion ( double  q[])
inline

Converts rotation matrix to quaternion.

Warning: for 3x3 matrix only! From libE57 'best practices' (http://www.libe57.org/best.html)

Parameters
qquaternion (w,x,y,z)
Returns
success

Definition at line 525 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values.

Referenced by SavePoseInformation().

◆ trace()

template<typename Scalar >
Scalar cloudViewer::SquareMatrixTpl< Scalar >::trace ( ) const
inline

◆ transpose()

template<typename Scalar >
void cloudViewer::SquareMatrixTpl< Scalar >::transpose ( )
inline

In-place transpose.

Definition at line 304 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::m_values, and std::swap().

Referenced by cloudViewer::SquareMatrixTpl< Scalar >::transposed().

◆ transposed()

template<typename Scalar >
SquareMatrixTpl cloudViewer::SquareMatrixTpl< Scalar >::transposed ( ) const
inline

Returns the transposed version of this matrix.

Definition at line 311 of file SquareMatrix.h.

References cloudViewer::SquareMatrixTpl< Scalar >::transpose().

Referenced by ccCompass::estimateStrain(), and cloudViewer::RegistrationTools::RegistrationProcedure().

Member Data Documentation

◆ m_values

template<typename Scalar >
Scalar** cloudViewer::SquareMatrixTpl< Scalar >::m_values = nullptr

The matrix rows.

public for easy/fast access

Definition at line 157 of file SquareMatrix.h.

Referenced by cloudViewer::SquareMatrixTpl< Scalar >::clear(), cloudViewer::Neighbourhood::computeCovarianceMatrix(), cloudViewer::GeometricalAnalysisTools::ComputeCovarianceMatrix(), cloudViewer::SquareMatrixTpl< Scalar >::computeDet(), Jacobi< Scalar >::ComputeEigenValuesAndVectors(), Jacobi< Scalar >::ComputeEigenValuesAndVectors2(), cloudViewer::Neighbourhood::computeQuadric(), cloudViewer::SquareMatrixTpl< Scalar >::deltaDeterminant(), ccCompass::estimateStructureNormals(), FromCCLibMatrix(), Jacobi< Scalar >::GetEigenVector(), cloudViewer::SquareMatrixTpl< Scalar >::getValue(), cloudViewer::SquareMatrixTpl< Scalar >::initFromQuaternion(), cloudViewer::SquareMatrixTpl< Scalar >::inv(), cloudViewer::SquareMatrixTpl< Scalar >::invalidate(), cloudViewer::SquareMatrixTpl< Scalar >::operator+=(), cloudViewer::SquareMatrixTpl< Scalar >::operator-=(), cloudViewer::SquareMatrixTpl< Scalar >::operator=(), cloudViewer::SquareMatrixTpl< Scalar >::print(), cloudViewer::RegistrationTools::RegistrationProcedure(), cloudViewer::SquareMatrixTpl< Scalar >::row(), cloudViewer::SquareMatrixTpl< Scalar >::scale(), cloudViewer::SquareMatrixTpl< Scalar >::setValue(), Jacobi< Scalar >::SortEigenValuesAndVectors(), cloudViewer::SquareMatrixTpl< Scalar >::SquareMatrixTpl(), cloudViewer::SquareMatrixTpl< Scalar >::toArray(), cloudViewer::SquareMatrixTpl< Scalar >::toGlMatrix(), cloudViewer::SquareMatrixTpl< Scalar >::toIdentity(), cloudViewer::SquareMatrixTpl< Scalar >::toQuaternion(), cloudViewer::SquareMatrixTpl< Scalar >::trace(), and cloudViewer::SquareMatrixTpl< Scalar >::transpose().


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