Coin Logo Coin3D is Free Software,
published under the BSD 3-clause license.
https://bitbucket.org/Coin3D/
http://www.kongsberg.com/kogt/
SbDPMatrix Class Reference

The SbDPMatrix class is a 4x4 dimensional representation of a double-precision matrix. More...

#include <Inventor/SbDPMatrix.h>

Public Member Functions

 SbDPMatrix (void)
 
 SbDPMatrix (const double a11, const double a12, const double a13, const double a14, const double a21, const double a22, const double a23, const double a24, const double a31, const double a32, const double a33, const double a34, const double a41, const double a42, const double a43, const double a44)
 
 SbDPMatrix (const SbDPMat &matrix)
 
 SbDPMatrix (const SbDPMat *matrix)
 
 SbDPMatrix (const SbMatrix &matrix)
 
 ~SbDPMatrix (void)
 
void setValue (const SbDPMat &m)
 
void setValue (const SbMatrix &m)
 
void setValue (const double *pMat)
 
const SbDPMat & getValue (void) const
 
void makeIdentity (void)
 
void setRotate (const SbDPRotation &q)
 
SbDPMatrix inverse (void) const
 
double det3 (int r1, int r2, int r3, int c1, int c2, int c3) const
 
double det3 (void) const
 
double det4 (void) const
 
SbBool equals (const SbDPMatrix &m, double tolerance) const
 
void getValue (SbDPMat &m) const
 
void setScale (const double s)
 
void setScale (const SbVec3d &s)
 
void setTranslate (const SbVec3d &t)
 
void setTransform (const SbVec3d &t, const SbDPRotation &r, const SbVec3d &s)
 
void setTransform (const SbVec3d &t, const SbDPRotation &r, const SbVec3d &s, const SbDPRotation &so)
 
void setTransform (const SbVec3d &translation, const SbDPRotation &rotation, const SbVec3d &scaleFactor, const SbDPRotation &scaleOrientation, const SbVec3d &center)
 
void getTransform (SbVec3d &t, SbDPRotation &r, SbVec3d &s, SbDPRotation &so) const
 
void getTransform (SbVec3d &translation, SbDPRotation &rotation, SbVec3d &scaleFactor, SbDPRotation &scaleOrientation, const SbVec3d &center) const
 
SbBool factor (SbDPMatrix &r, SbVec3d &s, SbDPMatrix &u, SbVec3d &t, SbDPMatrix &proj)
 
SbBool LUDecomposition (int index[4], double &d)
 
void LUBackSubstitution (int index[4], double b[4]) const
 
SbDPMatrix transpose (void) const
 
SbDPMatrixmultRight (const SbDPMatrix &m)
 
SbDPMatrixmultLeft (const SbDPMatrix &m)
 
void multMatrixVec (const SbVec3d &src, SbVec3d &dst) const
 
void multVecMatrix (const SbVec3d &src, SbVec3d &dst) const
 
void multDirMatrix (const SbVec3d &src, SbVec3d &dst) const
 
void multLineMatrix (const SbDPLine &src, SbDPLine &dst) const
 
void multVecMatrix (const SbVec4d &src, SbVec4d &dst) const
 
void print (FILE *fp) const
 
 operator double * (void)
 
 operator SbDPMat & (void)
 
double * operator[] (int i)
 
const double * operator[] (int i) const
 
SbDPMatrixoperator= (const SbDPMat &m)
 
SbDPMatrixoperator= (const SbDPMatrix &m)
 
SbDPMatrixoperator= (const SbDPRotation &q)
 
SbDPMatrixoperator*= (const SbDPMatrix &m)
 

Static Public Member Functions

static SbDPMatrix identity (void)
 

Friends

SbDPMatrix operator* (const SbDPMatrix &m1, const SbDPMatrix &m2)
 
int operator== (const SbDPMatrix &m1, const SbDPMatrix &m2)
 
int operator!= (const SbDPMatrix &m1, const SbDPMatrix &m2)
 

Detailed Description

The SbDPMatrix class is a 4x4 dimensional representation of a double-precision matrix.

This class is like the SbMatrix class, but uses double-precision floating point values for its elements. For more class documentation, see SbMatrix.

Since
Coin 2.0.

Constructor & Destructor Documentation

◆ SbDPMatrix() [1/5]

SbDPMatrix::SbDPMatrix ( void  )

The default constructor does nothing. The matrix will be uninitialized.

◆ SbDPMatrix() [2/5]

SbDPMatrix::SbDPMatrix ( const double  a11,
const double  a12,
const double  a13,
const double  a14,
const double  a21,
const double  a22,
const double  a23,
const double  a24,
const double  a31,
const double  a32,
const double  a33,
const double  a34,
const double  a41,
const double  a42,
const double  a43,
const double  a44 
)

Constructs a matrix instance with the given initial elements.

◆ SbDPMatrix() [3/5]

SbDPMatrix::SbDPMatrix ( const SbDPMat &  matrixref)

Constructs a matrix instance with the initial elements from the matrix argument.

◆ SbDPMatrix() [4/5]

SbDPMatrix::SbDPMatrix ( const SbDPMat *  matrixptr)

This constructor is courtesy of the Microsoft Visual C++ compiler.

◆ SbDPMatrix() [5/5]

SbDPMatrix::SbDPMatrix ( const SbMatrix matrixref)

This constructor converts a single-precision matrix to a double-precision matrix.

◆ ~SbDPMatrix()

SbDPMatrix::~SbDPMatrix ( void  )

Default destructor does nothing.

Member Function Documentation

◆ setValue() [1/3]

void SbDPMatrix::setValue ( const SbDPMat &  m)

Copies the elements from m into the matrix.

See also
getValue().

◆ setValue() [2/3]

void SbDPMatrix::setValue ( const SbMatrix m)

Copies the elements from m into the matrix.

See also
getValue().

◆ setValue() [3/3]

void SbDPMatrix::setValue ( const double *  m)

Copies the elements from m into the matrix.

See also
getValue().

◆ getValue() [1/2]

const SbDPMat & SbDPMatrix::getValue ( void  ) const

Returns a pointer to the 2 dimensional double array with the matrix elements.

See also
setValue().

◆ makeIdentity()

void SbDPMatrix::makeIdentity ( void  )

Set the matrix to be the identity matrix.

See also
identity().

◆ setRotate()

void SbDPMatrix::setRotate ( const SbDPRotation q)

Set matrix to be a rotation matrix with the given rotation.

See also
setTranslate(), setScale().

◆ inverse()

SbDPMatrix SbDPMatrix::inverse ( void  ) const

Return a new matrix which is the inverse matrix of this.

The user is responsible for checking that this is a valid operation to execute, by first making sure that the result of SbDPMatrix::det4() is not equal to zero.

◆ det3() [1/2]

double SbDPMatrix::det3 ( int  r1,
int  r2,
int  r3,
int  c1,
int  c2,
int  c3 
) const

Returns the determinant of the 3x3 submatrix specified by the row and column indices.

◆ det3() [2/2]

double SbDPMatrix::det3 ( void  ) const

Returns the determinant of the upper left 3x3 submatrix.

◆ det4()

double SbDPMatrix::det4 ( void  ) const

Returns the determinant of the matrix.

◆ equals()

SbBool SbDPMatrix::equals ( const SbDPMatrix m,
double  tolerance 
) const

Check if the m matrix is equal to this one, within the given tolerance value. The tolerance value is applied in the comparison on a component by component basis.

◆ getValue() [2/2]

void SbDPMatrix::getValue ( SbDPMat &  m) const

Return matrix components in the SbDPMat structure.

See also
setValue().

◆ identity()

SbDPMatrix SbDPMatrix::identity ( void  )
static

Return the identity matrix.

See also
makeIdentity().

◆ setScale() [1/2]

void SbDPMatrix::setScale ( const double  s)

Set matrix to be a pure scaling matrix. Scale factors are specified by s.

See also
setRotate(), setTranslate().

◆ setScale() [2/2]

void SbDPMatrix::setScale ( const SbVec3d s)

Set matrix to be a pure scaling matrix. Scale factors in x, y and z is specified by the s vector.

See also
setRotate(), setTranslate().

◆ setTranslate()

void SbDPMatrix::setTranslate ( const SbVec3d t)

Make this matrix into a pure translation matrix (no scale or rotation components) with the given vector t as the translation.

See also
setRotate(), setScale().

◆ setTransform() [1/3]

void SbDPMatrix::setTransform ( const SbVec3d t,
const SbDPRotation r,
const SbVec3d s 
)

Set translation, rotation and scaling all at once. The resulting matrix gets calculated like this:

M = S * R * T

where S, R and T is scaling, rotation and translation matrices.

See also
setTranslate(), setRotate(), setScale() and getTransform().

◆ setTransform() [2/3]

void SbDPMatrix::setTransform ( const SbVec3d t,
const SbDPRotation r,
const SbVec3d s,
const SbDPRotation so 
)

Set translation, rotation and scaling all at once with a specified scale orientation. The resulting matrix gets calculated like this:

M = Ro-¹ * S * Ro * R * T

where Ro is the scale orientation, and S, R and T is scaling, rotation and translation.

See also
setTranslate(), setRotate(), setScale() and getTransform().

◆ setTransform() [3/3]

void SbDPMatrix::setTransform ( const SbVec3d translation,
const SbDPRotation rotation,
const SbVec3d scaleFactor,
const SbDPRotation scaleOrientation,
const SbVec3d center 
)

Set translation, rotation and scaling all at once with a specified scale orientation and center point. The resulting matrix gets calculated like this:

M = -Tc * Ro-¹ * S * Ro * R * T * Tc

where Tc is the center point, Ro the scale orientation, S, R and T is scaling, rotation and translation.

See also
setTranslate(), setRotate(), setScale() and getTransform().

◆ getTransform() [1/2]

void SbDPMatrix::getTransform ( SbVec3d t,
SbDPRotation r,
SbVec3d s,
SbDPRotation so 
) const

Factor the matrix back into its translation, rotation, scale and scaleorientation components.

See also
factor()

◆ getTransform() [2/2]

void SbDPMatrix::getTransform ( SbVec3d translation,
SbDPRotation rotation,
SbVec3d scaleFactor,
SbDPRotation scaleOrientation,
const SbVec3d center 
) const

Factor the matrix back into its translation, rotation, scaleFactor and scaleorientation components. Will eliminate the center variable from the matrix.

See also
factor()

◆ factor()

SbBool SbDPMatrix::factor ( SbDPMatrix r,
SbVec3d s,
SbDPMatrix u,
SbVec3d t,
SbDPMatrix proj 
)

This function is not implemented in Coin.

See also
getTransform()

◆ LUDecomposition()

SbBool SbDPMatrix::LUDecomposition ( int  index[4],
double &  d 
)

This function produces a permuted LU decomposition of the matrix. It uses the common single-row-pivoting strategy.

FALSE is returned if the matrix is singular, which it never is, because of small adjustment values inserted if a singularity is found (as Open Inventor does too).

The parity argument is always set to 1.0 or -1.0. Don't really know what it's for, so it's not checked for correctness.

The index[] argument returns the permutation that was done on the matrix to LU-decompose it. index[i] is the row that row i was swapped with at step i in the decomposition, so index[] is not the actual permutation of the row indexes!

BUGS: The function does not produce results that are numerically identical with those produced by Open Inventor for the same matrices, because the pivoting strategy in OI was never fully understood.

See also
SbDPMatrix::LUBackSubstitution

◆ LUBackSubstitution()

void SbDPMatrix::LUBackSubstitution ( int  index[4],
double  b[4] 
) const

This function does a solve on the "Ax = b" system, given that the matrix is LU-decomposed in advance. First, a forward substitution is done on the lower system (Ly = b), and then a backwards substitution is done on the upper triangular system (Ux = y).

The index[] argument is the one returned from SbDPMatrix::LUDecomposition(), so see that function for an explanation.

The b[] argument must contain the b vector in "Ax = b" when calling the function. After the function has solved the system, the b[] vector contains the x vector.

BUGS: As is done by Open Inventor, unsolvable x values will not return NaN but 0.

◆ transpose()

SbDPMatrix SbDPMatrix::transpose ( void  ) const

Returns the transpose of this matrix.

◆ multRight()

SbDPMatrix & SbDPMatrix::multRight ( const SbDPMatrix m)

Let this matrix be right-multiplied by m. Returns reference to self.

See also
multLeft()

◆ multLeft()

SbDPMatrix & SbDPMatrix::multLeft ( const SbDPMatrix m)

Let this matrix be left-multiplied by m. Returns reference to self.

See also
multRight()

◆ multMatrixVec()

void SbDPMatrix::multMatrixVec ( const SbVec3d src,
SbVec3d dst 
) const

Multiply src vector with this matrix and return the result in dst. Multiplication is done with the vector on the right side of the expression, i.e. dst = M * src.

See also
multVecMatrix(), multDirMatrix() and multLineMatrix().

◆ multVecMatrix() [1/2]

void SbDPMatrix::multVecMatrix ( const SbVec3d src,
SbVec3d dst 
) const

Multiply src vector with this matrix and return the result in dst. Multiplication is done with the vector on the left side of the expression, i.e. dst = src * M.

It is safe to let src and dst be the same SbVec3d instance.

See also
multMatrixVec(), multDirMatrix() and multLineMatrix().

◆ multDirMatrix()

void SbDPMatrix::multDirMatrix ( const SbVec3d src,
SbVec3d dst 
) const

Multiplies src by the matrix. src is assumed to be a direction vector, and the translation components of the matrix are therefore ignored.

Multiplication is done with the vector on the left side of the expression, i.e. dst = src * M.

See also
multVecMatrix(), multMatrixVec() and multLineMatrix().

◆ multLineMatrix()

void SbDPMatrix::multLineMatrix ( const SbDPLine src,
SbDPLine dst 
) const

Multiplies line point with the full matrix and multiplies the line direction with the matrix without the translation components.

See also
multVecMatrix(), multMatrixVec() and multDirMatrix().

◆ multVecMatrix() [2/2]

void SbDPMatrix::multVecMatrix ( const SbVec4d src,
SbVec4d dst 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ print()

void SbDPMatrix::print ( FILE *  fp) const

Write out the matrix contents to the given file.

◆ operator double *()

SbDPMatrix::operator double * ( void  )

Return pointer to the matrix' 4x4 double array.

◆ operator SbDPMat &()

SbDPMatrix::operator SbDPMat & ( void  )

Return pointer to the matrix' 4x4 double array.

◆ operator[]() [1/2]

double * SbDPMatrix::operator[] ( int  i)

Returns pointer to the 4 element array representing a matrix row. i should be within [0, 3].

See also
getValue(), setValue().

◆ operator[]() [2/2]

const double * SbDPMatrix::operator[] ( int  i) const

Returns pointer to the 4 element array representing a matrix row. i should be within [0, 3].

See also
getValue(), setValue().

◆ operator=() [1/3]

SbDPMatrix & SbDPMatrix::operator= ( const SbDPMat &  m)

Assignment operator. Copies the elements from m to the matrix.

◆ operator=() [2/3]

SbDPMatrix & SbDPMatrix::operator= ( const SbDPMatrix m)

Assignment operator. Copies the elements from m to the matrix.

◆ operator=() [3/3]

SbDPMatrix & SbDPMatrix::operator= ( const SbDPRotation q)

Set matrix to be a rotation matrix with the given rotation.

See also
setRotate().

◆ operator*=()

SbDPMatrix & SbDPMatrix::operator*= ( const SbDPMatrix m)

Right-multiply with the m matrix.

See also
multRight().

Friends And Related Function Documentation

◆ operator*

SbDPMatrix operator* ( const SbDPMatrix m1,
const SbDPMatrix m2 
)
friend

Multiplies matrix m1 with matrix m2 and returns the resultant matrix.

◆ operator==

int operator== ( const SbDPMatrix m1,
const SbDPMatrix m2 
)
friend

Compare matrices to see if they are equal. For two matrices to be equal, all their individual elements must be equal.

See also
equals().

◆ operator!=

int operator!= ( const SbDPMatrix m1,
const SbDPMatrix m2 
)
friend

Compare matrices to see if they are not equal. For two matrices to not be equal, it is enough that at least one of their elements are unequal.

See also
equals().

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