Open Inventor Reference
SbMatrix Class Reference

4x4 matrix class. More...

#include <Inventor/SbLinear.h>

Public Member Functions

 SbMatrix ()
 Default constructor, initialized to identity.
 
 SbMatrix (float a11, float a12, float a13, float a14, float a21, float a22, float a23, float a24, float a31, float a32, float a33, float a34, float a41, float a42, float a43, float a44)
 Constructor given all 16 elements in row-major order.
 
 SbMatrix (const SbMat &m)
 Constructors.
 
void setValue (const SbMat &m)
 Sets value from 4x4 array of elements.
 
void setValue (const float *data)
 Sets value from a float array of 16 elements.
 
void makeIdentity ()
 Sets matrix to be identity.
 
void setRotate (const SbRotation &q)
 Sets matrix to rotate by given rotation.
 
void setScale (float s)
 Sets matrix to scale by given uniform factor.
 
void setScale (const SbVec3f &s)
 Sets matrix to scale by given vector.
 
void setTranslate (const SbVec3f &t)
 Sets matrix to translate by given vector.
 
void setTransform (const SbVec3f &translation, const SbRotation &rotation, const SbVec3f &scaleFactor, const SbRotation &scaleOrientation, const SbVec3f &center)
 Composes the matrix based on a translation, rotation, scale, orientation for scale, and center.
 
void setTransform (const SbVec3f &t, const SbRotation &r, const SbVec3f &s)
 Overloaded methods as a kludge because the compiler won't let us have SbVec3f(0,0,0) as a default value:
 
void setTransform (const SbVec3f &t, const SbRotation &r, const SbVec3f &s, const SbRotation &so)
 
void getTransform (SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f &center) const
 Decomposes the matrix into a translation, rotation, scale, and scale orientation.
 
void getTransform (SbVec3f &t, SbRotation &r, SbVec3f &s, SbRotation &so) const
 
void getValue (SbMat &m) const
 The following methods return matrix values and other info:
 
const SbMatgetValue () const
 
float 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).
 
float det3 () const
 Returns determinant of upper-left 3x3 submatrix.
 
float det4 () const
 Returns determinant of entire matrix.
 
bool factor (SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t, SbMatrix &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.
 
SbMatrix inverse () const
 Returns inverse of matrix.
 
bool LUDecomposition (int index[4], float &d)
 Perform in-place LU decomposition of matrix.
 
void LUBackSubstitution (int index[4], float b[4]) const
 Perform back-substitution on LU-decomposed matrix.
 
SbMatrix transpose () const
 Returns transpose of matrix.
 
SbMatrixmultRight (const SbMatrix &m)
 Multiplies matrix by given matrix on right or left.
 
SbMatrixmultLeft (const SbMatrix &m)
 Multiplies matrix by given matrix on right or left.
 
SbVec3f transformPoint (const SbVec3f &src) const
 Multiplies given row vector by matrix, giving vector result. Use this method to transform points from object coordinates to world coordinates. (MEVIS)
 
SbVec4f transformPoint (const SbVec4f &src) const
 Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns homogenous coordinate. (MEVIS)
 
SbVec3f transformDirection (const SbVec3f &src) const
 Multiplies given row vector by matrix, giving vector result.
 
SbLine transformLine (const SbLine &src) const
 Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of the matrix.
 
void multMatrixVec (const SbVec3f &src, SbVec3f &dst) const
 Multiplies matrix by given column vector, giving vector result.
 
void multVecMatrix (const SbVec3f &src, SbVec3f &dst) const
 Multiplies given row vector by matrix, giving vector result. Use this method to transform points from object coordinates to world coordinates.
 
void multVecMatrix (const SbVec4f &src, SbVec4f &dst) const
 Multiplies given row vector by matrix, giving vector result. Takes homogenous coordinate and returns homogenous coordinate.
 
void multVecMatrix (const SbVec3f &src, SbVec4f &dst) const
 Multiplies given row vector by matrix, giving vector result. Takes SbVec4(src,1.f) coordinate and returns homogenous coordinate.
 
void multDirMatrix (const SbVec3f &src, SbVec3f &dst) const
 Multiplies given row vector by matrix, giving vector result.
 
void multLineMatrix (const SbLine &src, SbLine &dst) const
 Multiplies the given line's origin by the matrix, and the line's direction by the rotation portion of the matrix.
 
void print (FILE *fp) const
 Prints a formatted version of the matrix to the given file pointer.
 
 operator float * ()
 Binary multiplication of matrices.
 
 operator SbMat & ()
 Cast: returns reference to 4x4 array.
 
float * operator[] (int i)
 Make it look like a usual matrix (so you can do m[3][2])
 
const float * operator[] (int i) const
 
SbMatrixoperator= (const SbMat &m)
 Sets value from 4x4 array of elements.
 
SbMatrixoperator= (const SbMatrix &m)
 Set the matrix from another SbMatrix.
 
SbMatrixoperator= (const SbRotation &q)
 Set the matrix from an SbRotation.
 
SbMatrixoperator*= (const SbMatrix &m)
 Performs right multiplication with another matrix.
 
bool equals (const SbMatrix &m, float tolerance) const
 Equality comparison within given tolerance, for each component.
 

Static Public Member Functions

static SbMatrix identity ()
 Returns an identity matrix.
 

Friends

INVENTOR_API SbMatrix operator* (const SbMatrix &m1, const SbMatrix &m2)
 Binary multiplication of matrices.
 
INVENTOR_API bool operator== (const SbMatrix &m1, const SbMatrix &m2)
 Equality comparison operator.
 
INVENTOR_API bool operator!= (const SbMatrix &m1, const SbMatrix &m2)
 

Detailed Description

4x4 matrix class/datatype used by many Inventor node and action classes. The matrices are stored in row-major order. {}

See Also
SbVec3f, SbRotation

Definition at line 823 of file SbLinear.h.

Constructor & Destructor Documentation

◆ SbMatrix() [1/3]

SbMatrix::SbMatrix ( )
inline

Definition at line 827 of file SbLinear.h.

◆ SbMatrix() [2/3]

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

◆ SbMatrix() [3/3]

SbMatrix::SbMatrix ( const SbMat m)

Member Function Documentation

◆ det3() [1/2]

float SbMatrix::det3 ( ) const
inline

Definition at line 914 of file SbLinear.h.

References det3().

Referenced by det3().

◆ det3() [2/2]

float SbMatrix::det3 ( int  r1,
int  r2,
int  r3,
int  c1,
int  c2,
int  c3 
) const

◆ det4()

float SbMatrix::det4 ( ) const

◆ equals()

bool SbMatrix::equals ( const SbMatrix m,
float  tolerance 
) const

◆ factor()

bool SbMatrix::factor ( SbMatrix r,
SbVec3f s,
SbMatrix u,
SbVec3f t,
SbMatrix proj 
) const

Any projection information is returned in proj. NOTE: the projection matrix is always set to identity.

◆ getTransform() [1/2]

void SbMatrix::getTransform ( SbVec3f t,
SbRotation r,
SbVec3f s,
SbRotation so 
) const
inline

Definition at line 898 of file SbLinear.h.

◆ getTransform() [2/2]

void SbMatrix::getTransform ( SbVec3f translation,
SbRotation rotation,
SbVec3f scaleFactor,
SbRotation scaleOrientation,
const SbVec3f center 
) const

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 ScaleOrientattion.

◆ getValue() [1/2]

const SbMat & SbMatrix::getValue ( ) const
inline

Definition at line 907 of file SbLinear.h.

◆ getValue() [2/2]

void SbMatrix::getValue ( SbMat m) const

Returns 4x4 array of elements

◆ identity()

static SbMatrix SbMatrix::identity ( )
static

◆ inverse()

SbMatrix SbMatrix::inverse ( ) const

Results are undefined for singular matrices. Uses LU decomposition.

◆ LUBackSubstitution()

void SbMatrix::LUBackSubstitution ( int  index[4],
float  b[4] 
) const

Index is permutation of rows from original matrix.

◆ LUDecomposition()

bool SbMatrix::LUDecomposition ( int  index[4],
float &  d 
)

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

◆ makeIdentity()

void SbMatrix::makeIdentity ( )

◆ multDirMatrix()

void SbMatrix::multDirMatrix ( const SbVec3f src,
SbVec3f dst 
) const

src is assumed to be a direction vector, so translation part of matrix is ignored. Note: if you wish to transform surface points and normals by a matrix, call multVecMatrix() for the points and call multDirMatrix() on the inverse transpose of the matrix for the normals.

◆ multLeft()

SbMatrix & SbMatrix::multLeft ( const SbMatrix m)

◆ multLineMatrix()

void SbMatrix::multLineMatrix ( const SbLine src,
SbLine dst 
) const

◆ multMatrixVec()

void SbMatrix::multMatrixVec ( const SbVec3f src,
SbVec3f dst 
) const

NOTE: Typically you should use multVecMatrix() instead, since object/world transforms normally use row vectors.

◆ multRight()

SbMatrix & SbMatrix::multRight ( const SbMatrix m)

◆ multVecMatrix() [1/3]

void SbMatrix::multVecMatrix ( const SbVec3f src,
SbVec3f dst 
) const

◆ multVecMatrix() [2/3]

void SbMatrix::multVecMatrix ( const SbVec3f src,
SbVec4f dst 
) const

◆ multVecMatrix() [3/3]

void SbMatrix::multVecMatrix ( const SbVec4f src,
SbVec4f dst 
) const

◆ operator float *()

SbMatrix::operator float * ( )
inline

Definition at line 995 of file SbLinear.h.

◆ operator SbMat &()

SbMatrix::operator SbMat & ( )
inline

Definition at line 998 of file SbLinear.h.

◆ operator*=()

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

Definition at line 1014 of file SbLinear.h.

◆ operator=() [1/3]

SbMatrix & SbMatrix::operator= ( const SbMat m)

◆ operator=() [2/3]

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

◆ operator=() [3/3]

SbMatrix & SbMatrix::operator= ( const SbRotation q)
inline

Definition at line 1011 of file SbLinear.h.

◆ operator[]() [1/2]

float * SbMatrix::operator[] ( int  i)
inline

Definition at line 1001 of file SbLinear.h.

◆ operator[]() [2/2]

const float * SbMatrix::operator[] ( int  i) const
inline

Definition at line 1002 of file SbLinear.h.

◆ print()

void SbMatrix::print ( FILE *  fp) const

◆ setRotate()

void SbMatrix::setRotate ( const SbRotation q)

◆ setScale() [1/2]

void SbMatrix::setScale ( const SbVec3f s)

◆ setScale() [2/2]

void SbMatrix::setScale ( float  s)

◆ setTransform() [1/3]

void SbMatrix::setTransform ( const SbVec3f t,
const SbRotation r,
const SbVec3f s 
)
inline

Definition at line 878 of file SbLinear.h.

◆ setTransform() [2/3]

void SbMatrix::setTransform ( const SbVec3f t,
const SbRotation r,
const SbVec3f s,
const SbRotation so 
)
inline

Definition at line 882 of file SbLinear.h.

◆ setTransform() [3/3]

void SbMatrix::setTransform ( const SbVec3f translation,
const SbRotation rotation,
const SbVec3f scaleFactor,
const SbRotation scaleOrientation,
const SbVec3f center 
)

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

◆ setTranslate()

void SbMatrix::setTranslate ( const SbVec3f t)

◆ setValue() [1/2]

void SbMatrix::setValue ( const float *  data)

◆ setValue() [2/2]

void SbMatrix::setValue ( const SbMat m)

◆ transformDirection()

SbVec3f SbMatrix::transformDirection ( const SbVec3f src) const
inline

src is assumed to be a direction vector, so translation part of matrix is ignored. Note: if you wish to transform surface points and normals by a matrix, call multVecMatrix() for the points and call multDirMatrix() on the inverse transpose of the matrix for the normals. (MEVIS)

Definition at line 960 of file SbLinear.h.

◆ transformLine()

SbLine SbMatrix::transformLine ( const SbLine src) const

(MEVIS)

◆ transformPoint() [1/2]

SbVec3f SbMatrix::transformPoint ( const SbVec3f src) const
inline

Definition at line 948 of file SbLinear.h.

◆ transformPoint() [2/2]

SbVec4f SbMatrix::transformPoint ( const SbVec4f src) const
inline

Definition at line 950 of file SbLinear.h.

◆ transpose()

SbMatrix SbMatrix::transpose ( ) const

Friends And Related Symbol Documentation

◆ operator!=

INVENTOR_API bool operator!= ( const SbMatrix m1,
const SbMatrix m2 
)
friend

Definition at line 1038 of file SbLinear.h.

◆ operator*

INVENTOR_API SbMatrix operator* ( const SbMatrix m1,
const SbMatrix m2 
)
friend

◆ operator==

INVENTOR_API bool operator== ( const SbMatrix m1,
const SbMatrix m2 
)
friend

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