SBMATRIX(3iv)
๐ SbMatrix ๐
okay so bestie, this is SbMatrix, and you're reading the 3IV manual page for it. yes we're doing linear algebra today and yes it slays. grab a strawberry ๐ and let's go.
โจ NAME โจ
SbMatrix โ 4x4 matrix class
๐ INHERITS FROM ๐
SbMatrix
not me inheriting from myself ๐ it's giving main character energy and honestly? iconic.
๐ SYNOPSIS ๐
first things first, you gotta let the compiler know you want in:
#include <Inventor/SbLinear.h>
and here's every single method that lives in this class, verbatim, no cap:
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(const SbMat &m)
void setValue(const SbMat &m)
void getValue(SbMat &m) const
const SbMat & getValue() const
void makeIdentity()
static SbMatrix identity()
void setRotate(const SbRotation &q)
void setScale(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
float det3(int r1, int r2, int r3, int c1, int c2, int c3)
const
float det3() const
float det4() const
SbBool factor(SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f
&t, SbMatrix &proj) const
SbMatrix inverse() const
SbBool LUDecomposition(int index[4], float &d)
void LUBackSubstitution(int index[4], float b[4]) const
SbMatrix transpose() 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 print(FILE *fp) const
float * operator float*()
SbMat operator SbMat&()
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)
SbMatrix operator *(const SbMatrix &m1, const SbMatrix &m2)
int operator ==(const SbMatrix &m1, const SbMatrix &m2)
int operator !=(const SbMatrix &m1, const SbMatrix &m2)
SbBool equals(const SbMatrix &m, float tolerance) const
๐ฆ DESCRIPTION ๐ฆ
so basically: it's a 4x4 matrix class/datatype, and like a lot of Inventor node and action classes are lowkey obsessed with it. it's everywhere. it's the blueprint.
and the tea you actually need to remember: the matrices are stored in row-major order. ๐ซถ write that on your hand. row. major. periodt.
๐ METHODS ๐
the constructors ๐
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(const SbMat &m)
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(const SbMat &m)โ these are the constructors. they construct. that's the whole vibe โจ
void setValue(const SbMat &m)โ sets the value from a 4x4 array of elements ๐void getValue(SbMat &m) constandconst SbMat & getValue() constโ hands you back that 4x4 array of elements. two flavors, pick your fighter ๐void makeIdentity()โ makes the matrix be the identity. glow-up to neutral โจstatic SbMatrix identity()โ returns an identity matrix. yes it'sstatic, yes you call it without an object, no we don't make the rules ๐void setRotate(const SbRotation &q)โ sets the matrix to rotate by the given rotation ๐void setScale(float s)โ sets the matrix to scale by the given uniform factorvoid setScale(const SbVec3f &s)โ sets the matrix to scale by the given vectorvoid setTranslate(const SbVec3f &t)โ sets the matrix to translate by the given vector ๐
the transform setters ๐ง
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 setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s),void setTransform(const SbVec3f &t, const SbRotation &r, const SbVec3f &s, const SbRotation &so), andvoid setTransform(const SbVec3f &translation, const SbRotation &rotation, const SbVec3f &scaleFactor, const SbRotation &scaleOrientation, const SbVec3f ¢er)โ composes the matrix out of a translation, rotation, scale, orientation for scale, and center. the center is the center point for scaling and rotation, and the scaleOrientation picks the primary axes for the scale. it's giving full makeover in one call ๐
the transform getters ๐
void getTransform(SbVec3f &t, SbRotation &r, SbVec3f &s, SbRotation &so) constโ returns the translation, rotation, scale, and scale orientation components of the matrix. the four-piece combo ๐void getTransform(SbVec3f &translation, SbRotation &rotation, SbVec3f &scaleFactor, SbRotation &scaleOrientation, const SbVec3f ¢er) constโ decomposes the matrix into a translation, rotation, scale, and scale orientation. any projection information is discarded. and heads up: the decomposition depends on your choice of center point for rotation and scaling, which is optional as the last parameter. and note that if the center is0,decompose()is the same asfactor()wheretis translation,uis rotation,sis scaleFactor, andris ScaleOrientation. iykyk ๐
determinants, we love a good determinant ๐งฎ
float det3(int r1, int r2, int r3, int c1, int c2, int c3) constโ returns the determinant of the 3x3 submatrix composed of the given row and column indices (0-3for each) ๐float det3() constโ returns the determinant of the upper-left 3x3 submatrixfloat det4() constโ returns the determinant of the entire matrix. the whole thing. no crumbs. ๐ฅ
factor, inverse, and the LU girls ๐
SbBool factor(SbMatrix &r, SbVec3f &s, SbMatrix &u, SbVec3f &t, SbMatrix &proj) constโ factors a matrixminto 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.
NOTE: the projection matrix is always set to identity. like always always. no exceptions bestie.
SbMatrix inverse() constโ returns the inverse of the matrix. results are undefined for singular matrices ๐จ so like, please don't. it uses LU decomposition.SbBool LUDecomposition(int index[4], float &d)โ performs an in-place LU decomposition of the matrix.indexis the index of rows in the matrix, anddis the parity of the row swaps. returnsFALSEif the matrix is singular ๐void LUBackSubstitution(int index[4], float b[4]) constโ performs back-substitution on an LU-decomposed matrix.indexis the permutation of rows from the original matrix.SbMatrix transpose() constโ returns the transpose of the matrix. flip it and reverse it ๐ฆ
multiplying things ๐ธ
SbMatrix & multRight(const SbMatrix &m)andSbMatrix & multLeft(const SbMatrix &m)โ multiplies the matrix by the given matrix on the right or on the left. choose your side ๐ซถvoid multMatrixVec(const SbVec3f &src, SbVec3f &dst) constโ multiplies the matrix by the given column vector, giving a vector resultvoid multVecMatrix(const SbVec3f &src, SbVec3f &dst) constโ multiplies the given row vector by the matrix, giving a vector resultvoid multDirMatrix(const SbVec3f &src, SbVec3f &dst) constโ multiplies the given row vector by the matrix, giving a vector result.srcis assumed to be a direction vector, so the translation part of the matrix is ignored. and listen up bestie: if you wish to transform surface points and normals by a matrix, callmultVecMatrix()for the points and callmultDirMatrix()on the inverse transpose of the matrix for the normals. this one's a classic exam question fr fr ๐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 โจ
utility & casting ๐
void print(FILE *fp) constโ prints a formatted version of the matrix to the given file pointer. debugging era ๐จ๏ธfloat * operator float*()โ cast: returns a pointer to the storage of the first elementSbMat operator SbMat&()โ cast: returns a reference to the 4x4 arrayfloat * operator [](int i)andconst float * operator [](int i) constโ makes it look like a usual matrix, so you can dom[3][2]. and honestly?m[3][2]is such a mood ๐
assignment operators ๐ง
SbMatrix & operator =(const SbMat &m)โ sets the value from a 4x4 array of elementsSbMatrix & operator =(const SbMatrix &m)โ sets the matrix from anotherSbMatrixSbMatrix & operator =(const SbRotation &q)โ sets the matrix from anSbRotation
math operators ๐ฅ
SbMatrix & operator *=(const SbMatrix &m)โ performs right multiplication with another matrixSbMatrix operator *(const SbMatrix &m1, const SbMatrix &m2)โ binary multiplication of matrices. two matrices walk in, one walks out ๐
comparison girlies โญ
int operator ==(const SbMatrix &m1, const SbMatrix &m2)andint operator !=(const SbMatrix &m1, const SbMatrix &m2)โ equality comparison operators. are they the same or are they not, the eternal question ๐SbBool equals(const SbMatrix &m, float tolerance) constโ equality comparison within the giventolerance, for each component. so like, close enough counts ๐
๐ SEE ALSO ๐
SbVec3fSbRotation
go read those too, they're besties with this one ๐ฆ
and that's the whole page, bestie!! you just read the SbMatrix(3IV) manual, which lives in the SbMatrix(3IV)() source/version corner of the world โ so if you ever need to cite it, that's your girl, footer and all. mwah ๐
๐โจ
๐ฆ where this page comes from
- debian bookworm: inventor-doc 2.1.5-10+dfsg-2 ยท LGPL-2.0-or-later
- debian trixie: inventor-doc 2.1.6+ds-2 ยท LGPL-2.0-or-later
- ubuntu jammy: inventor-doc 2.1.5-10-24
- ubuntu noble: inventor-doc 2.1.5-10+dfsg-2.1build2 ยท LGPL-2.0-or-later
- ubuntu questing: inventor-doc 2.1.6+ds-2
- ubuntu resolute: inventor-doc 2.1.6.1+ds-1 ยท LGPL-2.0-or-later
- ubuntu stonking: inventor-doc 2.1.6.1+ds-1 ยท LGPL-2.0-or-later
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms