SbMatrix(3)
π SbMatrix(3) π
Coin's 4x4 matrix page, and yes bestie, it's giving main character energy.
β¨ NAME β¨
SbMatrix β The SbMatrix class is a 4x4 dimensional representation of a matrix. periodt.
π¦ SYNOPSIS π¦
#include <Inventor/SbMatrix.h>
π Public Member Functions π
SbMatrix (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 SbDPMatrix &matrix)πΈ~SbMatrix (void)πvoid setValue (const SbMat &m)π«Άvoid setValue (const SbDPMatrix &m)πvoid setValue (const float *pMat)π₯const SbMat & getValue (void) constπvoid makeIdentity (void)πvoid setRotate (const SbRotation &q)βSbMatrix inverse (void) constπfloat det3 (int r1, int r2, int r3, int c1, int c2, int c3) constπfloat det3 (void) constπfloat det4 (void) constπ§SbBool equals (const SbMatrix &m, float tolerance) constπvoid getValue (SbMat &m) constπvoid setScale (const float s)β¨void setScale (const SbVec3f &s)πvoid setTranslate (const SbVec3f &t)π¦void setTransform (const SbVec3f &t, const SbRotation &r, const SbVec3f &s)πΈvoid setTransform (const SbVec3f &t, const SbRotation &r, const SbVec3f &s, const SbRotation &so)πvoid setTransform (const SbVec3f &translation, const SbRotation &rotation, const SbVec3f &scaleFactor, const SbRotation &scaleOrientation, const SbVec3f ¢er)π«Άvoid getTransform (SbVec3f &t, SbRotation &r, SbVec3f &s, SbRotation &so) constπvoid getTransform (SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f ¢er) constπ₯SbBool factor (SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t, SbMatrix &proj) constπSbBool LUDecomposition (int index[4], float &d)πvoid LUBackSubstitution (int index[4], float b[4]) constβSbMatrix transpose (void) constπSbMatrix & multRight (const SbMatrix &m)πSbMatrix & multLeft (const SbMatrix &m)πvoid multMatrixVec (const SbVec3f &src, SbVec3f &dst) constπ§void multVecMatrix (const SbVec3f &src, SbVec3f &dst) constπvoid multDirMatrix (const SbVec3f &src, SbVec3f &dst) constπvoid multLineMatrix (const SbLine &src, SbLine &dst) constβ¨void multVecMatrix (const SbVec4f &src, SbVec4f &dst) constπvoid print (FILE *fp) constπ¦operator float * (void)πΈoperator SbMat & (void)πfloat * operator[] (int i)π«Άconst float * operator[] (int i) constπSbMatrix & operator= (const SbMat &m)π₯SbMatrix & operator= (const SbMatrix &m)πSbMatrix & operator= (const SbRotation &q)πSbMatrix & operator*= (const SbMatrix &m)β
π Static Public Member Functions π
static SbMatrix identity (void)π
π« Detailed Description π«
The SbMatrix class is a 4x4 dimensional representation of a matrix. That's the whole assignment, bestie.
SbMatrix is used by many other classes in Coin. It provides storage for a 4x4 matrix of single-precision floating point values. single-precision, not double, okay?
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 newcomers to the API. Don't let the textbooks gaslight you.
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 the SbMatrix::multRight() method. right-hand side, literally.
If you have a matrix in row-order from some other source, it can be "converted" to column-order by transposing it with SbMatrix::transpose(). A simple example will help to explain this. vibe check: transpose it.
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. same principle, different order, slay.
π Constructor & Destructor Documentation π
SbMatrix::SbMatrix (void )
The default constructor does nothing. The matrix will be uninitialized. not me leaving it blank on purpose.
SbMatrix::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)
Constructs a matrix instance with the given initial elements. all 16 of them, bestie.
SbMatrix::SbMatrix (const SbMat & matrixref)
Constructs a matrix instance with the initial elements from the matrix argument. copy that vibe.
SbMatrix::SbMatrix (const SbMat * matrixptr)
This constructor is courtesy of the Microsoft Visual C++ compiler. ty, MSVC.
SbMatrix::SbMatrix (const SbDPMatrix & matrixref) [explicit]
This constructor is courtesy of the Microsoft Visual C++ compiler. again, ty, MSVC.
SbMatrix::~SbMatrix (void )
Default destructor does nothing. it just exists and then leaves, iconic.
π Member Function Documentation π
ok bestie this is the big one, so hydrate, sit criss-cross, and let's go method by method. no skipping, we're eating the whole plate π
void SbMatrix::setValue (const SbMat & m)
Copies the elements from m into the matrix. that's the whole thing β it's giving copy-paste but make it linear algebra π
See also: getValue().
void SbMatrix::setValue (const SbDPMatrix & m)
Same energy, different source type: copies the elements from m into the matrix.
void SbMatrix::setValue (const float * pMat)
Copies the elements from pMat into the matrix. raw float pointer moment β¨
See also: getValue().
const SbMat & SbMatrix::getValue (void ) const
Returns a pointer to the 2 dimensional float array with the matrix elements. yes bestie, the actual numbers π«Ά
See also: setValue().
void SbMatrix::makeIdentity (void )
Sets the matrix to be the identity matrix. it's the factory-reset, the clean-slate, the "new semester new me" π
See also: identity().
void SbMatrix::setRotate (const SbRotation & q)
Sets the matrix to be a rotation matrix with the given rotation.
See also: setTranslate(), setScale().
SbMatrix SbMatrix::inverse (void ) const
Returns a new matrix which is the inverse matrix of this one.
π¨ bestie listen β the user is responsible for checking that this is a valid operation to execute, by first making sure that the result of SbMatrix::det4() is not equal to zero. you can't just inverse whenever you feel like it, the math will simply not have it π
float SbMatrix::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. you pick the rows (r1, r2, r3) and the columns (c1, c2, c3), it does the math πΈ
float SbMatrix::det3 (void ) const
Returns the determinant of the upper left 3x3 submatrix. the no-argument version just assumes top-left corner, she's confident like that.
float SbMatrix::det4 (void ) const
Returns the determinant of the matrix. the whole 4x4, no crumbs left.
SbBool SbMatrix::equals (const SbMatrix & m, float tolerance) const
Checks if the m matrix is equal to this one, within the given tolerance value. the tolerance gets applied in the comparison on a component-by-component basis, so it's not a vibes-only check, it's an actual per-component check β¨
void SbMatrix::getValue (SbMat & m) const
Returns the matrix components in the SbMat structure. the fill-up-the-argument flavor, not the return-a-pointer flavor.
See also: setValue().
SbMatrix SbMatrix::identity (void ) [static]
Returns the identity matrix. static, so you can grab it without having an instance first β lowkey convenient π
See also: makeIdentity().
void SbMatrix::setScale (const float s)
Sets the matrix to be a pure scaling matrix. The scale factors are specified by s. one number, scales everything the same π
See also: setRotate(), setTranslate().
void SbMatrix::setScale (const SbVec3f & s)
Sets the matrix to be a pure scaling matrix. The scale factors in x, y and z are specified by the s vector. so now you can stretch each axis independently, iconic π¦
See also: setRotate(), setTranslate().
void SbMatrix::setTranslate (const SbVec3f & t)
Makes this matrix into a pure translation matrix (no scale or rotation components) with the given vector t as the translation. just move, no spin, no stretch.
See also: setRotate(), setScale().
void SbMatrix::setTransform (const SbVec3f & t, const SbRotation & r, const SbVec3f & s)
Sets 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().
void SbMatrix::setTransform (const SbVec3f & t, const SbRotation & r, const SbVec3f & s, const SbRotation & so)
Sets translation, rotation and scaling all at once, but this time with a specified scale orientation. The resulting matrix gets calculated like this:
M = Ro^-1 * 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().
void SbMatrix::setTransform (const SbVec3f & translation, const SbRotation & rotation, const SbVec3f & scaleFactor, const SbRotation & scaleOrientation, const SbVec3f & center)
Sets translation, rotation and scaling all at once with a specified scale orientation and a center point. The resulting matrix gets calculated like this:
M = -Tc * Ro^-1 * 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().
void SbMatrix::getTransform (SbVec3f & t, SbRotation & r, SbVec3f & s, SbRotation & so) const
Factors the matrix back into its translation, rotation, scale and scale orientation components. reverse-engineering the whole glow-up π«
See also: factor()
void SbMatrix::getTransform (SbVec3f & translation, SbRotation & rotation, SbVec3f & scaleFactor, SbRotation & scaleOrientation, const SbVec3f & center) const
Factors the matrix back into its translation, rotation, scaleFactor and scaleorientation components. Will eliminate the center variable from the matrix.
See also: factor()
SbBool SbMatrix::factor (SbMatrix & r, SbVec3f & s, SbMatrix & u, SbVec3f & t, SbMatrix & proj) const
This function is not implemented in Coin.
π yeah. she's just a placeholder. do not call her expecting results.
See also: getTransform()
SbBool SbMatrix::LUDecomposition (int index[4], float & 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. so like... we tried bestie π
See also: SbMatrix::LUBackSubstitution
void SbMatrix::LUBackSubstitution (int index[4], float 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 SbMatrix::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, unsolvablexvalues will not returnNaNbut0. okay so instead of screaming "I DON'T KNOW" she just quietly says zero π
SbMatrix SbMatrix::transpose (void ) const
Returns the transpose of this matrix. flip it and reverse it π
SbMatrix & SbMatrix::multRight (const SbMatrix & m)
Lets this matrix be right-multiplied by m. Returns a reference to self.
This is the most common multiplication / concatenation operation when using column-order matrices, as SbMatrix instances are, by definition. so like, this is the default move π
See also: multRight()'s bestie multLeft() β wait, no, see multLeft().
See also: multLeft()
SbMatrix & SbMatrix::multLeft (const SbMatrix & m)
Lets this matrix be left-multiplied by m. Returns a reference to self.
(Be aware that it is more common to use the SbMatrix::multRight() operation, when doing concatenation of transformations, as SbMatrix instances are by definition in column-order, and uses post-multiplication for common geometry operations.)
See also: multRight()
void SbMatrix::multMatrixVec (const SbVec3f & src, SbVec3f & dst) const
Multiplies the src vector with this matrix and returns the result in dst. 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 the SbMatrix::multVecMatrix() operation, when doing vector transformations, as SbMatrix instances are by definition in column-order, and uses post-multiplication for common geometry operations.)
See also: multVecMatrix(), multDirMatrix() and multLineMatrix().
void SbMatrix::multVecMatrix (const SbVec3f & src, SbVec3f & dst) const
Multiplies the src vector with this matrix and returns 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 SbVec3f instance. (yes bestie, in-place, she's flexible β¨)
This method can be used (using the current model matrix) to transform a point from an object coordinate system to the world coordinate system.
This operation is what you would usually do when transforming vectors, as SbMatrix instances are, by definition, column-order matrices. the moment the vibes align π«Ά
See also: multMatrixVec(), multDirMatrix() and multLineMatrix().
void SbMatrix::multDirMatrix (const SbVec3f & src, SbVec3f & 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. directions don't get moved, only pointed, slay π§
Multiplication is done with the vector on the left side of the expression, i.e. dst = src * M.
See also: multVecMatrix(), multMatrixVec() and multLineMatrix().
void SbMatrix::multLineMatrix (const SbLine & src, SbLine & dst) const
Multiplies the line point with the full matrix and multiplies the line direction with the matrix without the translation components. so the point moves and the direction rotates β two-for-one deal π
See also: multVecMatrix(), multMatrixVec() and multDirMatrix().
void SbMatrix::multVecMatrix (const SbVec4f & src, SbVec4f & dst) const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. (the SbVec4f flavor, same energy, four whole components π)
void SbMatrix::print (FILE * fp) const
Writes out the matrix contents to the given file. spill the tea, but to a file π
SbMatrix::operator float * (void )
Returns a pointer to the matrix' 4x4 float array.
SbMatrix::operator SbMat & (void )
Returns a pointer to the matrix' 4x4 float array. (yes, same words as the one above, that's genuinely what the page says π)
float * SbMatrix::operator[] (int i)
Returns a pointer to the 4 element array representing a matrix row. i should be within [0, 3].
See also: getValue(), setValue().
const float * SbMatrix::operator[] (int i) const
Returns a pointer to the 4 element array representing a matrix row. i should be within [0, 3]. (the const version, for when you're just looking π)
See also: getValue(), setValue().
SbMatrix & SbMatrix::operator= (const SbMat & m)
Assignment operator. Copies the elements from m to the matrix.
SbMatrix & SbMatrix::operator= (const SbMatrix & m)
Assignment operator. Copies the elements from m to the matrix.
SbMatrix & SbMatrix::operator= (const SbRotation & q)
Sets the matrix to be a rotation matrix with the given rotation.
See also: setRotate().
SbMatrix & SbMatrix::operator*= (const SbMatrix & m)
Right-multiplies with the m matrix.
See also: multRight().
βοΈ Author βοΈ
Generated automatically by Doxygen for Coin from the source code. (not a human, just a robot doing its little robot best π)
and that's the whole page bestie!! this one's SbMatrix(3), version 4.0.10, dated Thu Jun 25 2026 00:00:00 β you now know more about matrices than like 99% of the population. go forth and multiply (literally). periodt πβ¨
π¦ where this page comes from
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 43: Coin4-devel 4.0.10-1.fc43 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- fedora 44: Coin4-devel 4.0.10-1.fc44 Β· BSD-3-Clause AND GPL-3.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms