Provided by: libcoin80-doc_3.1.4~abc9f50-4ubuntu2_all

**NAME**

SbMatrix - TheSbMatrixclass is a 4x4 dimensional representation of a matrix.SbMatrixis used by many other classes in Coin. It provides storage for a 4x4 matrix of single-precision floating point values.

**SYNOPSIS**

PublicMemberFunctionsSbMatrix(void)SbMatrix(const float a11, const float a12, const float a13, const float a14, const float a21, const float a22, const float a23, const float a24, const float a31, const float a32, const float a33, const float a34, const float a41, const float a42, const float a43, const float a44)SbMatrix(const SbMat &matrix)SbMatrix(const SbMat *matrix)SbMatrix(const classSbDPMatrix&matrix)~SbMatrix(void) voidsetValue(const SbMat &m) voidsetValue(const classSbDPMatrix&m) voidsetValue(const float *pMat) const SbMat &getValue(void) const voidmakeIdentity(void) voidsetRotate(constSbRotation&q)SbMatrixinverse(void) const floatdet3(int r1, int r2, int r3, int c1, int c2, int c3) const floatdet3(void) const floatdet4(void) const SbBoolequals(constSbMatrix&m, float tolerance) const voidgetValue(SbMat &m) const voidsetScale(const float s) voidsetScale(constSbVec3f&s) voidsetTranslate(constSbVec3f&t) voidsetTransform(constSbVec3f&t, constSbRotation&r, constSbVec3f&s) voidsetTransform(constSbVec3f&t, constSbRotation&r, constSbVec3f&s, constSbRotation&so) voidsetTransform(constSbVec3f&translation, constSbRotation&rotation, constSbVec3f&scaleFactor, constSbRotation&scaleOrientation, constSbVec3f¢er) voidgetTransform(SbVec3f&t,SbRotation&r,SbVec3f&s,SbRotation&so) const voidgetTransform(SbVec3f&translation,SbRotation&rotation,SbVec3f&scaleFactor,SbRotation&scaleOrientation, constSbVec3f¢er) const SbBoolfactor(SbMatrix&r,SbVec3f&s,SbMatrix&u,SbVec3f&t,SbMatrix&proj) SbBoolLUDecomposition(int index[4], float &d) voidLUBackSubstitution(int index[4], float b[4]) constSbMatrixtranspose(void) constSbMatrix&multRight(constSbMatrix&m)SbMatrix&multLeft(constSbMatrix&m) voidmultMatrixVec(constSbVec3f&src,SbVec3f&dst) const voidmultVecMatrix(constSbVec3f&src,SbVec3f&dst) const voidmultDirMatrix(constSbVec3f&src,SbVec3f&dst) const voidmultLineMatrix(constSbLine&src,SbLine&dst) const voidmultVecMatrix(constSbVec4f&src,SbVec4f&dst) const voidoperatorfloat*(void)operatorSbMat&(void) float *operator[](int i) const float *operator[](int i) constSbMatrix&operator=(const SbMat &m)SbMatrix&operator=(constSbMatrix&m)SbMatrix&operator=(constSbRotation&q)SbMatrix&operator*=(constSbMatrix&m)StaticPublicMemberFunctionsstaticSbMatrixidentity(void)FriendsSbMatrixoperator*(constSbMatrix&m1, constSbMatrix&m2) intoperator==(constSbMatrix&m1, constSbMatrix&m2) intoperator!=(constSbMatrix&m1, constSbMatrix&m2)

**Detailed** **Description**

TheSbMatrixclass is a 4x4 dimensional representation of a matrix.SbMatrixis used by many other classes in Coin. It provides storage for a 4x4 matrix of single-precision floating point values. By definition, matrices in Coin should be set up in column-order mode. This is the same order as used by e.g. OpenGL, but note that books on geometry often uses the opposite row- order mode, which can confuse new-comers to the API. Another way to think of column-order matrices is that they use post-order multiplications: that is, to concatenate a transformation from a second matrix with your current matrix, it should be multiplied on the right-hand side, i.e. with theSbMatrix::multRight()method. If you have a matrix in row-order from some other source, it can be 'converted' to column- order by transposing it withSbMatrix::transpose(). A simple example will help to explain this. With row-order matrices, a transformation matrix with position, rotation and scale looks like this: M = T * R * S Where T is translation, R is rotation and S is the scale. What this means is that scale is applied first. The scaled matrix is then rotated, and finally the scaled and rotated matrix is translated. When using column-order matrices, as done in Coin, matrices are represented slightly differently; the order of multiplication is reversed: M = S * R * T The transformation is just the same as the row-order matrix. The only difference being the order of multiplication. To understand why this is so, consider the sample transformation: M = T * R * S Converting M from a row-order matrix to a column-order matrix is done as follows: M^t = (T * R * S)^t M^t = ((T * R) * S)^t M^t = S^t * (T * R)^t M^t = S^t * R^t * T^t All left to be done is to remove the transpose symbols, and the matrices have been converted to column-order matrices: M = S * R * T This was done using the fact that: A^t = (B * C)^t = C^t * B^t Converting from column-order to row-order is done using the same principle.

**Constructor** **&** **Destructor** **Documentation**

SbMatrix::SbMatrix(void)The default constructor does nothing. The matrix will be uninitialized.SbMatrix::SbMatrix(constfloata11,constfloata12,constfloata13,constfloata14,constfloata21,constfloata22,constfloata23,constfloata24,constfloata31,constfloata32,constfloata33,constfloata34,constfloata41,constfloata42,constfloata43,constfloata44)Constructs a matrix instance with the given initial elements.SbMatrix::SbMatrix(constSbMat&matrixref)Constructs a matrix instance with the initial elements from thematrixargument.SbMatrix::SbMatrix(constSbMat*matrixptr)This constructor is courtesy of the Microsoft Visual C++ compiler.SbMatrix::~SbMatrix(void)Default destructor does nothing.

**Member** **Function** **Documentation**

voidSbMatrix::setValue(constSbMat&m)Copies the elements fromminto the matrix.SeeAlso:getValue().voidSbMatrix::setValue(constfloat*pMat)Copies the elements frompMatinto the matrix.SeeAlso:getValue().constSbMat&SbMatrix::getValue(void)constReturns a pointer to the 2 dimensional float array with the matrix elements.SeeAlso:setValue().voidSbMatrix::makeIdentity(void)Set the matrix to be the identity matrix.SeeAlso:identity().voidSbMatrix::setRotate(constSbRotation&q)Set matrix to be a rotation matrix with the given rotation.SeeAlso:setTranslate(),setScale().SbMatrixSbMatrix::inverse(void)constReturn 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 ofSbMatrix::det4()is not equal to zero.floatSbMatrix::det3(intr1,intr2,intr3,intc1,intc2,intc3)constReturns the determinant of the 3x3 submatrix specified by the row and column indices.floatSbMatrix::det3(void)constReturns the determinant of the upper left 3x3 submatrix.floatSbMatrix::det4(void)constReturns the determinant of the matrix.SbBoolSbMatrix::equals(constSbMatrix&m,floattolerance)constCheck if themmatrix is equal to this one, within the given tolerance value. The tolerance value is applied in the comparison on a component by component basis.voidSbMatrix::getValue(SbMat&m)constReturn matrix components in the SbMat structure.SeeAlso:setValue().SbMatrixSbMatrix::identity(void)[static]Return the identity matrix.SeeAlso:makeIdentity().voidSbMatrix::setScale(constfloats)Set matrix to be a pure scaling matrix. Scale factors are specified bys.SeeAlso:setRotate(),setTranslate().voidSbMatrix::setScale(constSbVec3f&s)Set matrix to be a pure scaling matrix. Scale factors in x, y and z is specified by thesvector.SeeAlso:setRotate(),setTranslate().voidSbMatrix::setTranslate(constSbVec3f&t)Make this matrix into a pure translation matrix (no scale or rotation components) with the given vector as the translation.SeeAlso:setRotate(),setScale().voidSbMatrix::setTransform(constSbVec3f&t,constSbRotation&r,constSbVec3f&s)Set translation, rotation and scaling all at once. The resulting matrix gets calculated like this: M = S * R * T whereS,RandTis scaling, rotation and translation matrices.SeeAlso:setTranslate(),setRotate(),setScale()andgetTransform().voidSbMatrix::setTransform(constSbVec3f&t,constSbRotation&r,constSbVec3f&s,constSbRotation&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 * S * Ro * R * T whereRois the scale orientation, andS,RandTis scaling, rotation and translation.SeeAlso:setTranslate(),setRotate(),setScale()andgetTransform().voidSbMatrix::setTransform(constSbVec3f&translation,constSbRotation&rotation,constSbVec3f&scaleFactor,constSbRotation&scaleOrientation,constSbVec3f¢er)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 * S * Ro * R * T * Tc whereTcis the center point,Rothe scale orientation,S,RandTis scaling, rotation and translation.SeeAlso:setTranslate(),setRotate(),setScale()andgetTransform().voidSbMatrix::getTransform(SbVec3f&t,SbRotation&r,SbVec3f&s,SbRotation&so)constFactor the matrix back into its translation, rotation, scale and scaleorientation components.SeeAlso:factor()voidSbMatrix::getTransform(SbVec3f&translation,SbRotation&rotation,SbVec3f&scaleFactor,SbRotation&scaleOrientation,constSbVec3f¢er)constFactor the matrix back into itstranslation,rotation,scaleFactorandscaleorientationcomponents. Will eliminate thecentervariable from the matrix.SeeAlso:factor()SbBoolSbMatrix::factor(SbMatrix&r,SbVec3f&s,SbMatrix&u,SbVec3f&t,SbMatrix&proj)This function is not implemented in Coin.SeeAlso:getTransform()SbBoolSbMatrix::LUDecomposition(intindex[4],float&d)This function produces a permuted LU decomposition of the matrix. It uses the common single-row-pivoting strategy.FALSEis 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.SeeAlso:SbMatrix::LUBackSubstitutionvoidSbMatrix::LUBackSubstitution(intindex[4],floatb[4])constThis 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 fromSbMatrix::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.SbMatrixSbMatrix::transpose(void)constReturns the transpose of this matrix.SbMatrix&SbMatrix::multRight(constSbMatrix&m)Let this matrix be right-multiplied bym. Returns reference to self. This is the most common multiplication / concatenation operation when using column-order matrices, asSbMatrixinstances are, by definition.SeeAlso:multLeft()SbMatrix&SbMatrix::multLeft(constSbMatrix&m)Let this matrix be left-multiplied bym. Returns reference to self. (Be aware that it is more common to use theSbMatrix::multRight()operation, when doing concatenation of transformations, asSbMatrixinstances are by definition in column-order, and uses post-multiplication for common geometry operations.)SeeAlso:multRight()voidSbMatrix::multMatrixVec(constSbVec3f&src,SbVec3f&dst)constMultiplysrcvector with this matrix and return the result indst. Multiplication is done with the vector on the right side of the expression, i.e. dst = M * src. (Be aware that it is more common to use theSbMatrix::multVecMatrix()operation, when doing vector transformations, asSbMatrixinstances are by definition in column-order, and uses post-multiplication for common geometry operations.)SeeAlso:multVecMatrix(),multDirMatrix()andmultLineMatrix().voidSbMatrix::multVecMatrix(constSbVec3f&src,SbVec3f&dst)constMultiplysrcvector with this matrix and return the result indst. Multiplication is done with the vector on the left side of the expression, i.e. dst = src * M. It is safe to letsrcanddstbe the sameSbVec3finstance. This method can be used (using the current model matrix) to transform a point from an object coordinate systems to the world coordinate system. This operation is what you would usually do when transforming vectors, asSbMatrixinstances are, by definition, column-order matrices.SeeAlso:multMatrixVec(),multDirMatrix()andmultLineMatrix().voidSbMatrix::multDirMatrix(constSbVec3f&src,SbVec3f&dst)constMultipliessrcby the matrix.srcis 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.SeeAlso:multVecMatrix(),multMatrixVec()andmultLineMatrix().voidSbMatrix::multLineMatrix(constSbLine&src,SbLine&dst)constMultiplies line point with the full matrix and multiplies the line direction with the matrix without the translation components.SeeAlso:multVecMatrix(),multMatrixVec()andmultDirMatrix().voidSbMatrix::multVecMatrix(constSbVec4f&src,SbVec4f&dst)constThis is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.voidSbMatrix::print(FILE*fp)constWrite out the matrix contents to the given file.SbMatrix::operatorfloat*(void)Return pointer to the matrix' 4x4 float array.SbMatrix::operatorSbMat&(void)Return pointer to the matrix' 4x4 float array.float*SbMatrix::operator[](inti)Returns pointer to the 4 element array representing a matrix row.ishould be within [0, 3].SeeAlso:getValue(),setValue().constfloat*SbMatrix::operator[](inti)constReturns pointer to the 4 element array representing a matrix row.ishould be within [0, 3].SeeAlso:getValue(),setValue().SbMatrix&SbMatrix::operator=(constSbMat&m)Assignment operator. Copies the elements frommto the matrix.SbMatrix&SbMatrix::operator=(constSbMatrix&m)Assignment operator. Copies the elements frommto the matrix.SbMatrix&SbMatrix::operator=(constSbRotation&q)Set matrix to be a rotation matrix with the given rotation.SeeAlso:setRotate().SbMatrix&SbMatrix::operator*=(constSbMatrix&m)Right-multiply with themmatrix.SeeAlso:multRight().

**Friends** **And** **Related** **Function** **Documentation**

SbMatrixoperator*(constSbMatrix&m1,constSbMatrix&m2)[friend]Multiplies matrixm1with matrixm2and returns the resultant matrix.intoperator==(constSbMatrix&m1,constSbMatrix&m2)[friend]Compare matrices to see if they are equal. For two matrices to be equal, all their individual elements must be equal.SeeAlso:equals().intoperator!=(constSbMatrix&m1,constSbMatrix&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.SeeAlso:equals().

**Author**

Generated automatically by Doxygen for Coin from the source code.