Open Inventor Release 2024.2.0
 
Loading...
Searching...
No Matches
SbMatrixd Class Reference

VSG extension 4x4 matrix class (double precision). More...

#include <Inventor/SbMatrix.h>

Public Member Functions

 SbMatrixd ()
 Default constructor.
 
 SbMatrixd (double a11, double a12, double a13, double a14, double a21, double a22, double a23, double a24, double a31, double a32, double a33, double a34, double a41, double a42, double a43, double a44)
 Constructor.
 
 SbMatrixd (const SbMatd &m)
 Constructor.
 
void setValue (const SbMatd &m)
 Sets value from 4x4 array of elements.
 
void setValue (const double *pMat)
 Sets value from a 16 value double array.
 
void setValue (const SbMatrix &m)
 Sets values from a single precision matrix.
 
void makeIdentity ()
 Sets matrix to be identity.
 
void setRotate (const SbRotationd &q)
 Sets matrix to rotate by given rotation.
 
void setScale (double s)
 Sets matrix to scale by given uniform factor.
 
void setScale (const SbVec3d &s)
 Sets matrix to scale by given vector.
 
void setTranslate (const SbVec3d &t)
 Sets matrix to translate by given vector.
 
void setTransform (const SbVec3d &translation, const SbRotationd &rotation, const SbVec3d &scaleFactor, const SbRotationd &scaleOrientation, const SbVec3d &center)
 Composes the matrix based on a translation, rotation, scale, orientation for scale, and center.
 
void setTransform (const SbVec3d &t, const SbRotationd &r, const SbVec3d &s)
 Composes the matrix based on a translation, rotation, and scale.
 
void setTransform (const SbVec3d &t, const SbRotationd &r, const SbVec3d &s, const SbRotationd &so)
 Composes the matrix based on a translation, rotation, scale, and orientation for scale.
 
void getTransform (SbVec3d &translation, SbRotationd &rotation, SbVec3d &scaleFactor, SbRotationd &scaleOrientation, const SbVec3d &center) const
 Decomposes the matrix into a translation, rotation, scale, and scale orientation.
 
void getTransform (SbVec3d &t, SbRotationd &r, SbVec3d &s, SbRotationd &so) const
 Return translation, rotation, scale, and scale orientation components of the matrix.
 
void getValue (SbMatd &m) const
 Returns matrix as a 4x4 array of elements.
 
const SbMatd & getValue () const
 Returns matrix as a 4x4 array of elements.
 
double det3 (int r1, int r2, int r3, int c1, int c2, int c3) const
 Returns determinant of 3x3 submatrix composed of given row and column indices (0-3 for each).
 
double det3 () const
 Returns determinant of upper-left 3x3 submatrix.
 
double det4 () const
 Returns determinant of entire matrix.
 
SbBool factor (SbMatrixd &r, SbVec3d &s, SbMatrixd &u, SbVec3d &t, SbMatrixd &proj) const
 Factors a matrix m into 5 pieces: m = r s r^ u t, where r^ means transpose of r, and r and u are rotations, s is a scale, and t is a translation.
 
SbMatrixd inverse () const
 Returns inverse of matrix.
 
void translate (const SbVec3d &translation)
 Translates this matrice by the given vector.
 
void scale (const SbVec3d &scaleFactor)
 Scales this matrice by the given vector.
 
SbBool LUDecomposition (int index[4], double &d)
 Perform in-place LU decomposition of matrix.
 
void LUBackSubstitution (int index[4], double b[4]) const
 Perform back-substitution on LU-decomposed matrix.
 
SbMatrixd transpose () const
 Returns transpose of matrix.
 
SbMatrixdmultRight (const SbMatrixd &m)
 Post-multiplies the matrix by given matrix.
 
SbMatrixdmultLeft (const SbMatrixd &m)
 Pre-multiplies the matrix by given matrix.
 
void multMatrixVec (const SbVec3d &src, SbVec3d &dst) const
 Post-multiplies matrix by given column vector, giving a 3D vector result.
 
void multVecMatrix (const SbVec3d &src, SbVec3d &dst) const
 Pre-multiplies matrix by the given row vector, giving a 3D vector result.
 
void multVecMatrix (const SbVec3d &src, SbVec4d &dst) const
 Pre-multiplies matrix by the given row vector, giving vector result in homogeneous coordinates.
 
void multDirMatrix (const SbVec3d &src, SbVec3d &dst) const
 Pre-multiplies the matrix by the given row vector, giving vector result.
 
void multLineMatrix (const SbLined &src, SbLined &dst) const
 Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of the matrix.
 
SbVec4d operator* (const SbVec4d &v)
 Multiply matrix by given vector.
 
void print (FILE *fp) const
 Prints a formatted version of the matrix to the given file pointer.
 
 operator double * ()
 Cast: returns pointer to storage of first element.
 
 operator SbMatd & ()
 Cast: returns reference to 4x4 array.
 
double * operator[] (int i)
 Make it look like a usual matrix (so you can do m[3][2]).
 
const double * operator[] (int i) const
 Make it look like a usual matrix (so you can do m[3][2]).
 
SbMatrixdoperator= (const SbMatd &m)
 Sets value from 4x4 array of elements.
 
SbMatrixdoperator= (const SbMatrixd &m)
 Set the matrix from another SbMatrixd.
 
SbMatrixdoperator= (const SbRotationd &q)
 Set the matrix from an SbRotationd.
 
SbMatrixdoperator*= (const SbMatrixd &m)
 Post-multiplies the matrix by the given matrix (equivalent to multRight() method).
 
SbBool equals (const SbMatrixd &m, double tolerance) const
 Equality comparison within given tolerance, for each component.
 
bool isInvertible () const
 Returns true if the matrix is invertible.
 

Static Public Member Functions

static SbMatrixd identity ()
 Returns an identity matrix.
 

Friends

SbVec4d operator* (const SbVec4d &v, const SbMatrixd &m)
 Multiplies matrices by vector, returning a vector result.
 
SbMatrixd operator* (const SbMatrixd &m1, const SbMatrixd &m2)
 Multiplies two matrices, returning a matrix result.
 
int operator== (const SbMatrixd &m1, const SbMatrixd &m2)
 Equality comparison operator.
 
int operator!= (const SbMatrixd &m1, const SbMatrixd &m2)
 Inequality comparison operator.
 

Detailed Description

VSG extension 4x4 matrix class (double precision).

4x4 double precision matrix class/datatype. Although Open Inventor fields store only single precision values, for certain applications it is useful and convenient to be able to store and manipulate double precision values, for example, double precision coordinate data or values that will be used for further computation.

See SbMatrix for discussion of storage layout and usage of matrices.

SEE ALSO

SbMatrix, SbMatrix3, SbRotation, SbRotationd, SbVec2d, SbVec2f, SbVec2i32, SbVec2s, SbVec3d, SbVec3f, SbVec3i32, SbVec3s, SbVec4b, SbVec4d, SbVec4f, SbVec4i32, SbVec4s, SbVec4ub, SbVec4ui32, SbVec4us

Definition at line 756 of file SbMatrix.h.

Constructor & Destructor Documentation

◆ SbMatrixd() [1/3]

SbMatrixd::SbMatrixd ( )
inline

Default constructor.

The matrix is initialized with zeros.

Definition at line 762 of file SbMatrix.h.

◆ SbMatrixd() [2/3]

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

Constructor.

◆ SbMatrixd() [3/3]

SbMatrixd::SbMatrixd ( const SbMatd &  m)

Constructor.

Member Function Documentation

◆ det3() [1/2]

double SbMatrixd::det3 ( ) const
inline

Returns determinant of upper-left 3x3 submatrix.

Definition at line 924 of file SbMatrix.h.

◆ det3() [2/2]

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

Returns determinant of 3x3 submatrix composed of given row and column indices (0-3 for each).

◆ det4()

double SbMatrixd::det4 ( ) const

Returns determinant of entire matrix.

◆ equals()

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

Equality comparison within given tolerance, for each component.

◆ factor()

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

Factors a matrix m into 5 pieces: m = r s r^ u t, where r^ means transpose of r, and r and u are rotations, s is a scale, and t is a translation.

Any projection information is returned in proj.

◆ getTransform() [1/2]

void SbMatrixd::getTransform ( SbVec3d t,
SbRotationd r,
SbVec3d s,
SbRotationd so 
) const

Return translation, rotation, scale, and scale orientation components of the matrix.

◆ getTransform() [2/2]

void SbMatrixd::getTransform ( SbVec3d translation,
SbRotationd rotation,
SbVec3d scaleFactor,
SbRotationd scaleOrientation,
const SbVec3d center 
) const

Decomposes the matrix into a translation, rotation, scale, and scale orientation.

Any projection information is discarded. The decomposition depends upon choice of center point for rotation and scaling, which is optional as the last parameter. Note that if the center is 0, decompose() is the same as factor() where t is translation, u is rotation, s is scaleFactor, and r is scaleOrientation.

◆ getValue() [1/2]

const SbMatd & SbMatrixd::getValue ( ) const
inline

Returns matrix as a 4x4 array of elements.

Definition at line 913 of file SbMatrix.h.

◆ getValue() [2/2]

void SbMatrixd::getValue ( SbMatd &  m) const

Returns matrix as a 4x4 array of elements.

◆ identity()

static SbMatrixd SbMatrixd::identity ( )
static

Returns an identity matrix.

◆ inverse()

SbMatrixd SbMatrixd::inverse ( ) const

Returns inverse of matrix.

Results are undefined for singular matrices. Uses LU decomposition.
Matrix is not modified.

◆ isInvertible()

bool SbMatrixd::isInvertible ( ) const

Returns true if the matrix is invertible.

◆ LUBackSubstitution()

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

Perform back-substitution on LU-decomposed matrix.

Index is permutation of rows from original matrix.

◆ LUDecomposition()

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

Perform in-place LU decomposition of matrix.

index is index of rows in matrix. d is the parity of row swaps. Returns FALSE if singular.

◆ makeIdentity()

void SbMatrixd::makeIdentity ( )

Sets matrix to be identity.

◆ multDirMatrix()

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

Pre-multiplies the matrix by the given row vector, giving vector result.

src is assumed to be a direction vector, so translation part of matrix is ignored.

Note: If you need to transform surface points and normal vectors by a matrix, call multVecMatrix() for the points and call multDirMatrix() for the normals. Generally normals should be transformed by the inverse transpose of the matrix. However note that the inverse transpose is equal to the original matrix if the matrix is orthonormal, i.e. purely rotational with no scaling or shearing.

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

◆ multLeft()

SbMatrixd & SbMatrixd::multLeft ( const SbMatrixd m)

Pre-multiplies the matrix by given matrix.

Matrix is replaced by the result.

◆ multLineMatrix()

void SbMatrixd::multLineMatrix ( const SbLined src,
SbLined dst 
) const

Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of the matrix.

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

◆ multMatrixVec()

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

Post-multiplies matrix by given column vector, giving a 3D vector result.

The intermediate homogeneous (vec4) value is converted to 3D by dividing the X, Y and Z components by W.

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

◆ multRight()

SbMatrixd & SbMatrixd::multRight ( const SbMatrixd m)

Post-multiplies the matrix by given matrix.

Matrix is replaced by the result.

◆ multVecMatrix() [1/2]

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

Pre-multiplies matrix by the given row vector, giving a 3D vector result.

The intermediate homogeneous (vec4) value is converted to 3D by dividing the X, Y and Z components by W.

Use this method to transform a point (position vector).
Use multDirMatrix() to transform a normal (direction vector).

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

◆ multVecMatrix() [2/2]

void SbMatrixd::multVecMatrix ( const SbVec3d src,
SbVec4d dst 
) const

Pre-multiplies matrix by the given row vector, giving vector result in homogeneous coordinates.

Use this method to transform a point (position vector).
Use multDirMatrix() to transform a normal (direction vector).

Parameters
srcthe source vector to transform
dstthe destination vector to retrieve the result It is safe to let src and dst be the same instance of SbVec3d.

◆ operator double *()

SbMatrixd::operator double * ( )
inline

Cast: returns pointer to storage of first element.

Definition at line 1057 of file SbMatrix.h.

◆ operator SbMatd &()

SbMatrixd::operator SbMatd & ( )
inline

Cast: returns reference to 4x4 array.

Definition at line 1062 of file SbMatrix.h.

◆ operator*()

SbVec4d SbMatrixd::operator* ( const SbVec4d v)

Multiply matrix by given vector.

Return m * v

◆ operator*=()

SbMatrixd & SbMatrixd::operator*= ( const SbMatrixd m)
inline

Post-multiplies the matrix by the given matrix (equivalent to multRight() method).

Matrix is replaced by the resulting matrix.

Definition at line 1093 of file SbMatrix.h.

◆ operator=() [1/3]

SbMatrixd & SbMatrixd::operator= ( const SbMatd &  m)

Sets value from 4x4 array of elements.

◆ operator=() [2/3]

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

Set the matrix from another SbMatrixd.

◆ operator=() [3/3]

SbMatrixd & SbMatrixd::operator= ( const SbRotationd q)
inline

Set the matrix from an SbRotationd.

Definition at line 1087 of file SbMatrix.h.

◆ operator[]() [1/2]

double * SbMatrixd::operator[] ( int  i)
inline

Make it look like a usual matrix (so you can do m[3][2]).

Definition at line 1067 of file SbMatrix.h.

◆ operator[]() [2/2]

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

Make it look like a usual matrix (so you can do m[3][2]).

Definition at line 1072 of file SbMatrix.h.

◆ print()

void SbMatrixd::print ( FILE *  fp) const

Prints a formatted version of the matrix to the given file pointer.

◆ scale()

void SbMatrixd::scale ( const SbVec3d scaleFactor)

Scales this matrice by the given vector.

◆ setRotate()

void SbMatrixd::setRotate ( const SbRotationd q)

Sets matrix to rotate by given rotation.

◆ setScale() [1/2]

void SbMatrixd::setScale ( const SbVec3d s)

Sets matrix to scale by given vector.

◆ setScale() [2/2]

void SbMatrixd::setScale ( double  s)

Sets matrix to scale by given uniform factor.

◆ setTransform() [1/3]

void SbMatrixd::setTransform ( const SbVec3d t,
const SbRotationd r,
const SbVec3d s 
)

Composes the matrix based on a translation, rotation, and scale.

A scale orientation value of (0,0,0,1) is used. The center point for scaling and rotation is (0,0,0).

◆ setTransform() [2/3]

void SbMatrixd::setTransform ( const SbVec3d t,
const SbRotationd r,
const SbVec3d s,
const SbRotationd so 
)

Composes the matrix based on a translation, rotation, scale, and orientation for scale.

The scaleOrientation chooses the primary axes for the scale. The center point for scaling and rotation is (0,0,0).

◆ setTransform() [3/3]

void SbMatrixd::setTransform ( const SbVec3d translation,
const SbRotationd rotation,
const SbVec3d scaleFactor,
const SbRotationd scaleOrientation,
const SbVec3d center 
)

Composes the matrix based on a translation, rotation, scale, orientation for scale, and center.

The scaleOrientation chooses the primary axes for the scale. The center is the center point for scaling and rotation.

◆ setTranslate()

void SbMatrixd::setTranslate ( const SbVec3d t)

Sets matrix to translate by given vector.

◆ setValue() [1/3]

void SbMatrixd::setValue ( const double *  pMat)
inline

Sets value from a 16 value double array.

Definition at line 786 of file SbMatrix.h.

◆ setValue() [2/3]

void SbMatrixd::setValue ( const SbMatd &  m)

Sets value from 4x4 array of elements.

◆ setValue() [3/3]

void SbMatrixd::setValue ( const SbMatrix m)

Sets values from a single precision matrix.

◆ translate()

void SbMatrixd::translate ( const SbVec3d translation)

Translates this matrice by the given vector.

◆ transpose()

SbMatrixd SbMatrixd::transpose ( ) const

Returns transpose of matrix.

Matrix is not modified.

Friends And Related Symbol Documentation

◆ operator!=

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

Inequality comparison operator.

Definition at line 1113 of file SbMatrix.h.

◆ operator* [1/2]

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

Multiplies two matrices, returning a matrix result.

◆ operator* [2/2]

SbVec4d operator* ( const SbVec4d v,
const SbMatrixd m 
)
friend

Multiplies matrices by vector, returning a vector result.

Return v*m.

◆ operator==

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

Equality comparison operator.


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