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 ¢er) |
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 ¢er) 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. | |
SbMatrixd & | multRight (const SbMatrixd &m) |
Post-multiplies the matrix by given matrix. | |
SbMatrixd & | multLeft (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]). | |
SbMatrixd & | operator= (const SbMatd &m) |
Sets value from 4x4 array of elements. | |
SbMatrixd & | operator= (const SbMatrixd &m) |
Set the matrix from another SbMatrixd. | |
SbMatrixd & | operator= (const SbRotationd &q) |
Set the matrix from an SbRotationd. | |
SbMatrixd & | operator*= (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. | |
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.
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.
|
inline |
Default constructor.
The matrix is initialized with zeros.
Definition at line 762 of file SbMatrix.h.
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::SbMatrixd | ( | const SbMatd & | m | ) |
Constructor.
|
inline |
Returns determinant of upper-left 3x3 submatrix.
Definition at line 924 of file SbMatrix.h.
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).
double SbMatrixd::det4 | ( | ) | const |
Returns determinant of entire matrix.
Equality comparison within given tolerance, for each component.
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.
void SbMatrixd::getTransform | ( | SbVec3d & | t, |
SbRotationd & | r, | ||
SbVec3d & | s, | ||
SbRotationd & | so | ||
) | const |
Return translation, rotation, scale, and scale orientation components of the matrix.
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.
|
inline |
Returns matrix as a 4x4 array of elements.
Definition at line 913 of file SbMatrix.h.
void SbMatrixd::getValue | ( | SbMatd & | m | ) | const |
Returns matrix as a 4x4 array of elements.
|
static |
Returns an identity matrix.
SbMatrixd SbMatrixd::inverse | ( | ) | const |
Returns inverse of matrix.
Results are undefined for singular matrices. Uses LU decomposition.
Matrix is not modified.
bool SbMatrixd::isInvertible | ( | ) | const |
Returns true if the matrix is invertible.
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.
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.
void SbMatrixd::makeIdentity | ( | ) |
Sets matrix to be identity.
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.
Pre-multiplies the matrix by given matrix.
Matrix is replaced by the result.
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.
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.
Post-multiplies the matrix by given matrix.
Matrix is replaced by the result.
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.
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).
src | the source vector to transform |
dst | the destination vector to retrieve the result It is safe to let src and dst be the same instance of SbVec3d. |
|
inline |
Cast: returns pointer to storage of first element.
Definition at line 1057 of file SbMatrix.h.
|
inline |
Cast: returns reference to 4x4 array.
Definition at line 1062 of file SbMatrix.h.
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.
SbMatrixd & SbMatrixd::operator= | ( | const SbMatd & | m | ) |
Sets value from 4x4 array of elements.
|
inline |
Set the matrix from an SbRotationd.
Definition at line 1087 of file SbMatrix.h.
|
inline |
Make it look like a usual matrix (so you can do m[3][2]).
Definition at line 1067 of file SbMatrix.h.
|
inline |
Make it look like a usual matrix (so you can do m[3][2]).
Definition at line 1072 of file SbMatrix.h.
void SbMatrixd::print | ( | FILE * | fp | ) | const |
Prints a formatted version of the matrix to the given file pointer.
void SbMatrixd::scale | ( | const SbVec3d & | scaleFactor | ) |
Scales this matrice by the given vector.
void SbMatrixd::setRotate | ( | const SbRotationd & | q | ) |
Sets matrix to rotate by given rotation.
void SbMatrixd::setScale | ( | const SbVec3d & | s | ) |
Sets matrix to scale by given vector.
void SbMatrixd::setScale | ( | double | s | ) |
Sets matrix to scale by given uniform factor.
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).
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).
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.
void SbMatrixd::setTranslate | ( | const SbVec3d & | t | ) |
Sets matrix to translate by given vector.
|
inline |
Sets value from a 16 value double array.
Definition at line 786 of file SbMatrix.h.
void SbMatrixd::setValue | ( | const SbMatd & | m | ) |
Sets value from 4x4 array of elements.
void SbMatrixd::setValue | ( | const SbMatrix & | m | ) |
Sets values from a single precision matrix.
void SbMatrixd::translate | ( | const SbVec3d & | translation | ) |
Translates this matrice by the given vector.
SbMatrixd SbMatrixd::transpose | ( | ) | const |
Returns transpose of matrix.
Matrix is not modified.
Inequality comparison operator.
Definition at line 1113 of file SbMatrix.h.
Multiplies two matrices, returning a matrix result.
Multiplies matrices by vector, returning a vector result.
Return v*m.