SbMatrix(3)
π SbMatrix π
okay bestie, welcome to SbMatrix(3) β the Library Functions Manual entry for the absolute icon that is the Coin 4x4 matrix class. this one's a big girl so she comes in parts, and this is part 1. strap in. π
β¨ NAME β¨
SbMatrix β the SbMatrix class is a 4x4 dimensional representation of a matrix. that's it. that's the vibe. a whole grid of numbers living its best life. π
πΈ SYNOPSIS πΈ
#include <Inventor/SbLinear.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 (void)
SbMatrix & operator= (const SbMat &m)
operator float * (void)
SbMatrix & operator= (const SbMatrix &m)
void setValue (const SbMat &m)
void setValue (const class SbDPMatrix &m)
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
operator SbMat & (void)
float * operator[] (int i)
const float * operator[] (int i) const
SbMatrix & operator= (const SbRotation &q)
SbMatrix & operator*= (const SbMatrix &m)
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)
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
π Static Public Member Functions
static SbMatrix identity (void)
π Detailed Description π
the SbMatrix class is a 4x4 dimensional representation of a matrix. periodt. π
SbMatrix is used by many other classes in Coin, so likeβ¦ she's kind of a big deal. she provides storage for a 4x4 matrix of single-precision floating point values. no cap. π«Ά
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 use the opposite row-order mode, which can confuse newcomers to the API. (ngl, it confuses everyone at first. it's giving "why is my matrix sideways". π)
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. iykyk. β¨
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, bestie, so here we go. π
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. so like: shrink, spin, scoot. π§
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. math ate that, honestly. π₯
π Constructor & Destructor Documentation π
SbMatrix::SbMatrix (void )
the default constructor does nothing. the matrix will be uninitialized.
β οΈ okay so listen β nothing happens here. zero. zilch. the matrix is uninitialized, so don't go reading values out of it expecting anything sane. it's giving "mystery numbers". π
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 sixteen of them, laid out one by one like a little squad. π«Ά
SbMatrix::SbMatrix (const SbMat & matrixref)
constructs a matrix instance with the initial elements from the matrix argument. copy the vibe, keep the numbers. β¨
SbMatrix::SbMatrix (const SbMat * matrixptr)
this constructor is courtesy of the Microsoft Visual C++ compiler. it's iconic, it's a little weird, it's here. π
SbMatrix::~SbMatrix (void )
default destructor does nothing. she leaves as quietly as she arrived. π¦
okay bestie that's part 1 done β the methods and all the juicy details are coming in part 2, don't go anywhere π
π Member Function Documentation π
okay bestie, this is the big one. every single method, no skips, no cap. let's go π«Ά
SbMatrix & SbMatrix::operator=(const SbMat & m)
Assignment operator, bestie. it literally just copies the elements from m over into the matrix. slay, that's it. π
SbMatrix::operator float *(void)
Hands you back a pointer to the matrix' 4x4 float array. yep. that's the whole thing. β¨
SbMatrix & SbMatrix::operator=(const SbMatrix & m)
Another assignment operator. copies the elements from m to the matrix. iconic behaviour honestly. π
void SbMatrix::setValue(const SbMat & m)
Copies the elements from m into the matrix.
π see also: getValue().
const SbMat & SbMatrix::getValue(void) const
Returns a pointer to the 2 dimensional float array with the matrix elements.
π see also: setValue().
void SbMatrix::makeIdentity(void)
Set the matrix to be the identity matrix. main character energy fr. π
π see also: identity().
void SbMatrix::setRotate(const SbRotation & q)
Set matrix to be a rotation matrix with the given rotation.
π see also: setTranslate(), setScale().
SbMatrix SbMatrix::inverse(void) const
Return a new matrix which is the inverse matrix of this.
β οΈ okay so this one is on YOU. 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. no cap, check it first. π
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.
float SbMatrix::det4(void) const
Returns the determinant of the matrix. the whole thing. the full vibe check. π
SbBool SbMatrix::equals(const SbMatrix & m, float tolerance) const
Check if the m matrix is equal to this one, within the given tolerance value. The tolerance value is applied in the comparison on a component by component basis. so like, close enough counts, but only within your tolerance bestie. π
SbMatrix::operator SbMat &(void)
Return pointer to the matrix' 4x4 float array. (yes, another one. the matrix really said "here's my array" twice. π )
float * SbMatrix::operator[](int i)
Returns 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 pointer to the 4 element array representing a matrix row. i should be within [0, 3]. same as above but const, and yes she's still serving. β¨
π see also: getValue(), setValue().
SbMatrix & SbMatrix::operator=(const SbRotation & q)
Set matrix to be a rotation matrix with the given rotation. (yes she's back, doing rotation things. π)
π see also: setRotate().
SbMatrix & SbMatrix::operator*=(const SbMatrix & m)
Right-multiply with the m matrix.
π see also: multRight().
void SbMatrix::getValue(SbMat & m) const
Return matrix components in the SbMat structure.
π see also: setValue().
SbMatrix SbMatrix::identity(void) [static]
Return the identity matrix. static, iconic, never changing. the moment. π
π see also: makeIdentity().
void SbMatrix::setScale(const float s)
Set matrix to be a pure scaling matrix. Scale factors are specified by s.
π see also: setRotate(), setTranslate().
void SbMatrix::setScale(const SbVec3f & s)
Set matrix to be a pure scaling matrix. Scale factors in x, y and z is specified by the s vector.
π see also: setRotate(), setTranslate().
void SbMatrix::setTranslate(const SbVec3f & t)
Make this matrix into a pure translation matrix (no scale or rotation components) with the given vector \t as the translation.
π see also: setRotate(), setScale().
void SbMatrix::setTransform(const SbVec3f & t, const SbRotation & r, const SbVec3f & s)
Set 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)
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
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)
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
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
Factor the matrix back into its translation, rotation, scale and scaleorientation components. it's giving reverse engineering, but make it cute. π§
π see also: factor()
void SbMatrix::getTransform(SbVec3f & translation, SbRotation & rotation, SbVec3f & scaleFactor, SbRotation & scaleOrientation, const SbVec3f & center) const
Factor 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)
This function is not implemented in Coin. π yeah. she's not here. she never showed up.
π 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. bestie the original devs literally shrugged. we're all just vibing. π
π 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, unsolvable x values will not returnNaNbut0. so like. no drama, just zero. lowkey a lie but okay. π
SbMatrix SbMatrix::transpose(void) const
Returns the transpose of this matrix. flip it, turn it, serve it. π
SbMatrix & SbMatrix::multRight(const SbMatrix & m)
Let this matrix be right-multiplied by m. Returns 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 one you'll reach for most of the time. π₯
π see also: multLeft()
SbMatrix & SbMatrix::multLeft(const SbMatrix & m)
Let this matrix be left-multiplied by m. Returns 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
Multiply src vector with this matrix and return 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
Multiply src vector with this matrix and return 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. (aliasing? never heard of her, she's fine here π«Ά)
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, as SbMatrix instances are, by definition, column-order matrices.
π 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. (direction only bestie, the translation is simply not invited to this party β¨)
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 line point with the full matrix and multiplies the line direction with the matrix without the translation components.
π 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. same energy, different types. π
void SbMatrix::print(FILE * fp) const
Write out the matrix contents to the given file. for when you just need to see her. πΈ
π¦ Author π¦
Generated automatically by Doxygen for Coin from the source code. yes bestie, no human hand-wrote this one, a robot did it and she ate. π
and that's the whole page, bestie!! this was Coin, Version 3.1.3, and the manpage is dated SbMatrix(3) β which is giving the tiniest date label of all time but honestly? iconic. go forth and multiply (matrices, obviously). πβ¨
π¦ where this page comes from
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 43: Coin3-devel 3.1.3-40.fc43 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- fedora 44: Coin3-devel 3.1.3-42.fc44 Β· GPL-2.0-only
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms