ALBA
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
albaMatrix3x3 Class Reference

#include <albaMatrix3x3.h>

Inheritance diagram for albaMatrix3x3:
Inheritance graph
[legend]
Collaboration diagram for albaMatrix3x3:
Collaboration graph
[legend]

Public Member Functions

 albaTypeMacro (albaMatrix3x3, albaObject)
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaMatrix3x3 ()
 
virtual ~albaMatrix3x3 ()
 
albaMatrix3x3operator= (const albaMatrix3x3 &mat)
 
 albaMatrix3x3 (albaMatrix3x3 &mat)
 
void DeepCopy (albaMatrix3x3 *mat)
 
void MultiplyVector (const double in[3], double out[3])
 
albaMatrix3x3Elements GetElements () const
 
void SetElement (int i, int j, double value)
 
double GetElement (int i, int j) const
 
void GetVersor (int axis, double versor[3])
 
void Zero ()
 
void Identity ()
 
void Transpose ()
 
void Invert ()
 
void Orthogonalize ()
 
double Determinant ()
 
void QuaternionToMatrix (const double quat[4])
 
void MatrixToQuaternion (double quat[4])
 
void SingularValueDecomposition (double U[3][3], double w[3], double VT[3][3])
 
void LUFactor (int index[3])
 
void LUSolve (const int index[3], double x[3])
 
double * operator[] (const unsigned int i)
 
const double * operator[] (unsigned int i) const
 
- Public Member Functions inherited from albaObject
 albaObject ()
 
virtual ~albaObject ()
 
virtual void Delete ()
 
virtual const char * GetTypeName () const
 
virtual bool IsA (const char *type_name) const
 
virtual bool IsA (const albaTypeID &type_id) const
 
virtual albaObjectNewObjectInstance () const =0
 
virtual const albaTypeIDGetTypeId () const
 
virtual void Print (std::ostream &os, const int indent=0) const
 
 albaObject (const albaObject &c)
 
- Public Member Functions inherited from albaTimeStamped
virtual void Modified ()
 
virtual unsigned long GetMTime ()
 

Static Public Member Functions

static void MultiplyVector (const float A[3][3], const float in[3], float out[3])
 
static void MultiplyVector (const double A[3][3], const double in[3], double out[3])
 
static void Multiply (const double A[3][3], const double B[3][3], double C[3][3])
 
static void Multiply (const albaMatrix3x3 &A, albaMatrix3x3 &B, albaMatrix3x3 &C)
 
static void GetVersor (int axis, const albaMatrix3x3 &matrix, double versor[3])
 
static void Zero (double elements[9])
 
static void Identity (double A[3][3])
 
static void Transpose (const double A[3][3], double AT[3][3])
 
static void Invert (const double A[3][3], double AI[3][3])
 
static void Orthogonalize (const double A[3][3], double B[3][3])
 
static void Diagonalize (const double A[3][3], double w[3], double V[3][3])
 
static double Determinant (double A[3][3])
 
static double Determinant (const double c1[3], const double c2[3], const double c3[3])
 
static double Determinant (double a1, double a2, double a3, double b1, double b2, double b3, double c1, double c2, double c3)
 
static void QuaternionToMatrix (const double quat[4], double A[3][3])
 
static void MatrixToQuaternion (const double A[3][3], double quat[4])
 
static void SingularValueDecomposition (const double A[3][3], double U[3][3], double w[3], double VT[3][3])
 
static int Jacobi (const double A[3][3], double w[3], double v[3][3])
 
static int JacobiN (double **a, int n, double *w, double **v)
 
static void LUFactor (double A[3][3], int index[3])
 
static void LUSolve (const double A[3][3], const int index[3], double x[3])
 
static double DegreesToRadians ()
 
static double Pi ()
 
static double RadiansToDegrees ()
 
static double Determinant2x2 (double a, double b, double c, double d)
 
static double Determinant2x2 (const double c1[2], const double c2[2])
 
static double Norm (const double x[3])
 
static void Cross (const double x[3], const double y[3], double z[3])
 
static double Normalize (double x[3])
 
- Static Public Member Functions inherited from albaObject
static const char * GetStaticTypeName ()
 
static bool IsStaticType (const char *type_name)
 
static bool IsStaticType (const albaTypeID &type_id)
 
static const albaTypeIDGetStaticTypeId ()
 
static albaObjectSafeDownCast (albaObject *o)
 

Protected Attributes

double m_Elements [3][3]
 
- Protected Attributes inherited from albaObject
bool m_HeapFlag
 
- Protected Attributes inherited from albaTimeStamped
albaMTime m_MTime
 

Detailed Description

albaMatrix3x3 - Simple 3x3 Matrix.

This class defines a simple 3x3 Matrix class, and some operators over it. This is typically used for internal algorithms, use albaMatrix for complex usage.

See also
albaMatrix

Definition at line 32 of file albaMatrix3x3.h.

Constructor & Destructor Documentation

◆ albaMatrix3x3() [1/2]

albaMatrix3x3::albaMatrix3x3 ( )

◆ ~albaMatrix3x3()

virtual albaMatrix3x3::~albaMatrix3x3 ( )
virtual

◆ albaMatrix3x3() [2/2]

albaMatrix3x3::albaMatrix3x3 ( albaMatrix3x3 mat)

Member Function Documentation

◆ albaTypeMacro()

albaMatrix3x3::albaTypeMacro ( albaMatrix3x3  ,
albaObject   
)

◆ Print()

virtual void albaMatrix3x3::Print ( std::ostream &  os,
const int  indent = 0 
) const
virtual

print debug information for this object

Reimplemented from albaObject.

◆ operator=()

albaMatrix3x3 & albaMatrix3x3::operator= ( const albaMatrix3x3 mat)

◆ DeepCopy()

void albaMatrix3x3::DeepCopy ( albaMatrix3x3 mat)

copy the given matrix content

◆ MultiplyVector() [1/3]

static void albaMatrix3x3::MultiplyVector ( const float  A[3][3],
const float  in[3],
float  out[3] 
)
static

Multiply a vector by a 3x3 matrix.

The result is placed in out.

◆ MultiplyVector() [2/3]

static void albaMatrix3x3::MultiplyVector ( const double  A[3][3],
const double  in[3],
double  out[3] 
)
static

Multiply a vector by a 3x3 matrix.

The result is placed in out.

◆ MultiplyVector() [3/3]

void albaMatrix3x3::MultiplyVector ( const double  in[3],
double  out[3] 
)
inline

Multiply a vector by this matrix.

The result is placed in out.

Definition at line 55 of file albaMatrix3x3.h.

References MultiplyVector().

Referenced by MultiplyVector().

Here is the call graph for this function:

◆ Multiply() [1/2]

static void albaMatrix3x3::Multiply ( const double  A[3][3],
const double  B[3][3],
double  C[3][3] 
)
static

Multiply one 3x3 matrix by another according to C = AB.

◆ Multiply() [2/2]

static void albaMatrix3x3::Multiply ( const albaMatrix3x3 A,
albaMatrix3x3 B,
albaMatrix3x3 C 
)
inlinestatic

Multiply this matrix by another according to C = AB.

Definition at line 62 of file albaMatrix3x3.h.

◆ GetElements()

albaMatrix3x3Elements albaMatrix3x3::GetElements ( ) const
inline

Definition at line 65 of file albaMatrix3x3.h.

◆ SetElement()

void albaMatrix3x3::SetElement ( int  i,
int  j,
double  value 
)
inline

Sets the element i,j in the matrix.

Remember to call explicitly Modified when using this function.

Definition at line 70 of file albaMatrix3x3.h.

◆ GetElement()

double albaMatrix3x3::GetElement ( int  i,
int  j 
) const
inline

Returns the element i,j from the matrix.

Definition at line 73 of file albaMatrix3x3.h.

◆ GetVersor() [1/2]

static void albaMatrix3x3::GetVersor ( int  axis,
const albaMatrix3x3 matrix,
double  versor[3] 
)
static

Get the given matrix versor.

Static version.

◆ GetVersor() [2/2]

void albaMatrix3x3::GetVersor ( int  axis,
double  versor[3] 
)
inline

Get the given matrix versor.

Definition at line 78 of file albaMatrix3x3.h.

References GetVersor().

Referenced by GetVersor().

Here is the call graph for this function:

◆ Zero() [1/2]

void albaMatrix3x3::Zero ( )
inline

Set all of the elements to zero.

Static version.

Definition at line 81 of file albaMatrix3x3.h.

References albaTimeStamped::Modified(), and Zero().

Referenced by Zero().

Here is the call graph for this function:

◆ Zero() [2/2]

static void albaMatrix3x3::Zero ( double  elements[9])
static

Set all of the elements to zero.

◆ Identity() [1/2]

void albaMatrix3x3::Identity ( )
inline

Set equal to Identity matrix.

Definition at line 86 of file albaMatrix3x3.h.

References Identity(), and albaTimeStamped::Modified().

Referenced by Identity().

Here is the call graph for this function:

◆ Identity() [2/2]

static void albaMatrix3x3::Identity ( double  A[3][3])
static

◆ Transpose() [1/2]

static void albaMatrix3x3::Transpose ( const double  A[3][3],
double  AT[3][3] 
)
static

Transpose the 3x3 matrix.

◆ Transpose() [2/2]

void albaMatrix3x3::Transpose ( )
inline

Definition at line 91 of file albaMatrix3x3.h.

References albaTimeStamped::Modified(), and Transpose().

Referenced by Transpose().

Here is the call graph for this function:

◆ Invert() [1/2]

static void albaMatrix3x3::Invert ( const double  A[3][3],
double  AI[3][3] 
)
static

Invert the 3x3 matrix.

◆ Invert() [2/2]

void albaMatrix3x3::Invert ( )
inline

Definition at line 95 of file albaMatrix3x3.h.

References Invert(), and albaTimeStamped::Modified().

Referenced by Invert().

Here is the call graph for this function:

◆ Orthogonalize() [1/2]

static void albaMatrix3x3::Orthogonalize ( const double  A[3][3],
double  B[3][3] 
)
static

Orthogonalize a 3x3 matrix and put the result in B.

If matrix A has a negative determinant, then B will be a rotation plus a flip i.e. it will have a determinant of -1.

◆ Orthogonalize() [2/2]

void albaMatrix3x3::Orthogonalize ( )
inline

Orthogonalize this matrix in place.

If this matrix has a negative determinant, then the result will be a rotation plus a flip i.e. it will have a determinant of -1.

Definition at line 107 of file albaMatrix3x3.h.

References albaTimeStamped::Modified(), and Orthogonalize().

Referenced by Orthogonalize().

Here is the call graph for this function:

◆ Diagonalize()

static void albaMatrix3x3::Diagonalize ( const double  A[3][3],
double  w[3],
double  V[3][3] 
)
static

Diagonalize a symmetric 3x3 matrix and return the eigenvalues in w and the eigenvectors in the columns of V.

The matrix V will have a positive determinant, and the three eigenvectors will be aligned as closely as possible with the x, y, and z axes.

◆ Determinant() [1/4]

double albaMatrix3x3::Determinant ( double  A[3][3])
inlinestatic

Return the determinant of a 3x3 matrix.

Definition at line 235 of file albaMatrix3x3.h.

◆ Determinant() [2/4]

double albaMatrix3x3::Determinant ( )
inline

Compute the determinant of the matrix and return it.

Definition at line 120 of file albaMatrix3x3.h.

References Determinant().

Referenced by Determinant().

Here is the call graph for this function:

◆ Determinant() [3/4]

double albaMatrix3x3::Determinant ( const double  c1[3],
const double  c2[3],
const double  c3[3] 
)
inlinestatic

Definition at line 243 of file albaMatrix3x3.h.

◆ Determinant() [4/4]

double albaMatrix3x3::Determinant ( double  a1,
double  a2,
double  a3,
double  b1,
double  b2,
double  b3,
double  c1,
double  c2,
double  c3 
)
inlinestatic

Definition at line 252 of file albaMatrix3x3.h.

References Determinant2x2().

Here is the call graph for this function:

◆ QuaternionToMatrix() [1/2]

static void albaMatrix3x3::QuaternionToMatrix ( const double  quat[4],
double  A[3][3] 
)
static

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand.

◆ QuaternionToMatrix() [2/2]

void albaMatrix3x3::QuaternionToMatrix ( const double  quat[4])
inline

Convert a quaternion to a 3x3 rotation matrix.

The quaternion does not have to be normalized beforehand.

Definition at line 138 of file albaMatrix3x3.h.

References QuaternionToMatrix().

Referenced by QuaternionToMatrix().

Here is the call graph for this function:

◆ MatrixToQuaternion() [1/2]

static void albaMatrix3x3::MatrixToQuaternion ( const double  A[3][3],
double  quat[4] 
)
static

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The method used is that of B.K.P. Horn.

◆ MatrixToQuaternion() [2/2]

void albaMatrix3x3::MatrixToQuaternion ( double  quat[4])
inline

Convert a 3x3 matrix into a quaternion.

This will provide the best possible answer even if the matrix is not a pure rotation matrix. The method used is that of B.K.P. Horn.

Definition at line 150 of file albaMatrix3x3.h.

References MatrixToQuaternion().

Referenced by MatrixToQuaternion().

Here is the call graph for this function:

◆ SingularValueDecomposition() [1/2]

static void albaMatrix3x3::SingularValueDecomposition ( const double  A[3][3],
double  U[3][3],
double  w[3],
double  VT[3][3] 
)
static

Perform singular value decomposition on a 3x3 matrix.

This is not done using a conventional SVD algorithm, instead it is done using Orthogonalize3x3 and Diagonalize3x3. Both output matrices U and VT will have positive determinants, and the w values will be arranged such that the three rows of VT are aligned as closely as possible with the x, y, and z axes respectively. If the determinant of A is negative, then the three w values will be negative.

◆ SingularValueDecomposition() [2/2]

void albaMatrix3x3::SingularValueDecomposition ( double  U[3][3],
double  w[3],
double  VT[3][3] 
)
inline

Perform singular value decomposition on a 3x3 matrix.

See the static version.

Definition at line 165 of file albaMatrix3x3.h.

◆ Jacobi()

static int albaMatrix3x3::Jacobi ( const double  A[3][3],
double  w[3],
double  v[3][3] 
)
static

◆ JacobiN()

static int albaMatrix3x3::JacobiN ( double **  a,
int  n,
double *  w,
double **  v 
)
static

Jacobi iteration for the solution of eigenvectors/eigenvalues of this 3x3 real symmetric matrix.

Output eigenvalues in w; and output eigenvectors in v. Resulting eigenvalues/vectors are sorted in decreasing order; eigenvectors are normalized. JacobiN iteration for the solution of eigenvectors/eigenvalues of a nxn real symmetric matrix. Square nxn matrix a; size of matrix in n; output eigenvalues in w; and output eigenvectors in v. Resulting eigenvalues/vectors are sorted in decreasing order; eigenvectors are normalized. w and v need to be allocated previously

◆ LUFactor() [1/2]

static void albaMatrix3x3::LUFactor ( double  A[3][3],
int  index[3] 
)
static

LU Factorization of a 3x3 matrix.

The diagonal elements are the multiplicative inverse of those in the standard LU factorization.

◆ LUFactor() [2/2]

void albaMatrix3x3::LUFactor ( int  index[3])
inline

Definition at line 194 of file albaMatrix3x3.h.

References LUFactor().

Referenced by LUFactor().

Here is the call graph for this function:

◆ LUSolve() [1/2]

static void albaMatrix3x3::LUSolve ( const double  A[3][3],
const int  index[3],
double  x[3] 
)
static

LU back substitution for a 3x3 matrix.

The diagonal elements are the multiplicative inverse of those in the standard LU factorization.

◆ LUSolve() [2/2]

void albaMatrix3x3::LUSolve ( const int  index[3],
double  x[3] 
)
inline

Definition at line 200 of file albaMatrix3x3.h.

◆ DegreesToRadians()

static double albaMatrix3x3::DegreesToRadians ( )
inlinestatic

Useful constants.

(double-precision version)

Definition at line 205 of file albaMatrix3x3.h.

◆ Pi()

static double albaMatrix3x3::Pi ( )
inlinestatic

Definition at line 206 of file albaMatrix3x3.h.

◆ RadiansToDegrees()

static double albaMatrix3x3::RadiansToDegrees ( )
inlinestatic

Definition at line 207 of file albaMatrix3x3.h.

◆ operator[]() [1/2]

double * albaMatrix3x3::operator[] ( const unsigned int  i)
inline

bracket operator to access & write single elements

Definition at line 210 of file albaMatrix3x3.h.

◆ operator[]() [2/2]

const double * albaMatrix3x3::operator[] ( unsigned int  i) const
inline

bracket operator to access single elements

Definition at line 213 of file albaMatrix3x3.h.

◆ Determinant2x2() [1/2]

static double albaMatrix3x3::Determinant2x2 ( double  a,
double  b,
double  c,
double  d 
)
inlinestatic

Calculate the determinant of a 2x2 matrix: | a b | | c d |.

Definition at line 216 of file albaMatrix3x3.h.

Referenced by Determinant().

◆ Determinant2x2() [2/2]

static double albaMatrix3x3::Determinant2x2 ( const double  c1[2],
const double  c2[2] 
)
inlinestatic

Calculate the determinant of a 2x2 matrix with columns c1 and c2.

Definition at line 219 of file albaMatrix3x3.h.

◆ Norm()

static double albaMatrix3x3::Norm ( const double  x[3])
inlinestatic

Compute the norm of 3-vector (double-precision version).

Definition at line 223 of file albaMatrix3x3.h.

Referenced by Normalize().

◆ Cross()

void albaMatrix3x3::Cross ( const double  x[3],
const double  y[3],
double  z[3] 
)
inlinestatic

Definition at line 263 of file albaMatrix3x3.h.

◆ Normalize()

double albaMatrix3x3::Normalize ( double  x[3])
inlinestatic

Definition at line 272 of file albaMatrix3x3.h.

References Norm().

Here is the call graph for this function:

Member Data Documentation

◆ m_Elements

double albaMatrix3x3::m_Elements[3][3]
protected

internal representation

Definition at line 231 of file albaMatrix3x3.h.


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