Matrix33¶
#include <Imath/ImathMatrix.h>
The Matrix33
class template represents a 3x3 matrix, with
predefined typedefs for float
and double
.
There are also various utility functions that operate on matrices
defined in ImathMatrixAlgo.h
and described in Matrix
Functions.
Example:
#include <Imath/ImathMatrix.h>
#include <Imath/ImathMatrixAlgo.h>
void
matrix33_example()
{
Imath::M33f M (Imath::UNINITIALIZED); // uninitialized
M.makeIdentity();
assert (M[0][0] == 1.0f);
assert (M[0][1] == 0.0f);
Imath::M33f Minv = M.inverse();
Imath::M33f R;
assert (R == Imath::identity33f);
R.rotate (M_PI/4);
M = R * M;
Imath::V3f v3 (1.0f, 0.0f, 0.0f);
Imath::V3f r3 = v3 * M;
assert (r3.equalWithAbsError (Imath::V3f (0.707107f, 0.7071070f, 0.0f), 1e-6f));
}
-
template<class
T
>
classImath
::
Matrix33
¶ 3x3 transformation matrix
Constructors and Assignment
-
inline
Matrix33
(Uninitialized) noexcept¶ Uninitialized.
-
inline constexpr
Matrix33
() noexcept¶ Default constructor: initialize to identity 1 0 0 0 1 0 0 0 1.
-
inline constexpr
Matrix33
(const T a[3][3]) noexcept¶ Construct from 3x3 array a[0][0] a[0][1] a[0][2] a[1][0] a[1][1] a[1][2] a[2][0] a[2][1] a[2][2].
-
inline constexpr
Matrix33
(T a, T b, T c, T d, T e, T f, T g, T h, T i) noexcept¶ Construct from given scalar values a b c d e f g h i.
-
template<class
S
>
inline explicit constexprMatrix33
(const Matrix33<S> &v) noexcept¶ Construct from Matrix33 of another base type.
-
~Matrix33
() noexcept = default¶ Destructor.
Compatibility with Sb
Arithmetic and Comparison
-
inline constexpr bool
equalWithAbsError
(const Matrix33<T> &v, T e) const noexcept¶ Compare two matrices and test if they are “approximately equal”:
- Return
True if the coefficients of this and
m
are the same with an absolute error of no more than e, i.e., for all i, j:abs (this[i][j] - m[i][j]) <= e
-
inline constexpr bool
equalWithRelError
(const Matrix33<T> &v, T e) const noexcept¶ Compare two matrices and test if they are “approximately equal”:
- Return
True if the coefficients of this and m are the same with a relative error of no more than e, i.e., for all i, j:
abs (this[i] - v[i][j]) <= e * abs (this[i][j])
-
inline constexpr const Matrix33 &
operator-=
(const Matrix33 &v) noexcept¶ Component-wise subtraction.
-
inline constexpr const Matrix33 &
operator*=
(const Matrix33 &v) noexcept¶ Matrix-matrix multiplication.
-
inline constexpr Matrix33
operator*
(const Matrix33 &v) const noexcept¶ Matrix-matrix multiplication.
-
template<class
S
>
inline voidmultVecMatrix
(const Vec2<S> &src, Vec2<S> &dst) const noexcept¶ Vector-matrix multiplication: a homogeneous transformation by computing Vec3 (src.x, src.y, 1) * m and dividing by the result’s third element.
- Parameters
[in] src
: The input vector[out] dst
: The output vector
Maniplation
-
inline void
makeIdentity
() noexcept¶ Set to the identity matrix.
-
inline constexpr const Matrix33 &
invert
(bool singExc)¶ Invert in place using the determinant.
- Return
const reference to this
- Parameters
singExc
: If true, throw an exception if the matrix cannot be inverted.
-
inline constexpr const Matrix33 &
invert
() noexcept¶ Invert in place using the determinant.
- Return
const reference to this
-
inline constexpr Matrix33<T>
inverse
(bool singExc) const¶ Return the inverse using the determinant, leaving this unmodified.
- Parameters
singExc
: If true, throw an exception if the matrix cannot be inverted.
-
inline constexpr Matrix33<T>
inverse
() const noexcept¶ Return the inverse using the determinant, leaving this unmodified.
-
inline const Matrix33 &
gjInvert
(bool singExc)¶ Invert in place using the Gauss-Jordan method.
Significantly slower but more accurate than invert().
- Return
const reference to this
- Parameters
singExc
: If true, throw an exception if the matrix cannot be inverted.
-
inline const Matrix33 &
gjInvert
() noexcept¶ Invert in place using the Gauss-Jordan method.
Significantly slower but more accurate than invert().
- Return
const reference to this
-
inline Matrix33<T>
gjInverse
(bool singExc) const¶ Return the inverse using the Gauss-Jordan method, leaving this unmodified.
Significantly slower but more accurate than inverse().
-
inline Matrix33<T>
gjInverse
() const noexcept¶ Return the inverse using the Gauss-Jordan method.
Significantly slower, leaving this unmodified. Slower but more accurate than inverse().
-
inline constexpr T
minorOf
(const int r, const int c) const noexcept¶ Calculate the matrix minor of the (r,c) element.
-
inline constexpr T
fastMinor
(const int r0, const int r1, const int c0, const int c1) const noexcept¶ Build a minor using the specified rows and columns.
-
template<class
S
>
const Matrix33 &setRotation
(S r) noexcept¶ Set matrix to rotation by r (in radians)
- Return
const referenced to this
-
inline constexpr const Matrix33 &
setScale
(T s) noexcept¶ Set matrix to scale by given uniform factor.
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &setScale
(const Vec2<S> &s) noexcept¶ Set matrix to scale by given vector.
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &scale
(const Vec2<S> &s) noexcept¶ Scale the matrix by s.
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &setTranslation
(const Vec2<S> &t) noexcept¶ Set matrix to translation by given vector.
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &translate
(const Vec2<S> &t) noexcept¶ Translate the matrix by t.
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &setShear
(const S &h) noexcept¶ Set matrix to shear x for each y coord.
by given factor xy
- Return
const referenced to this
-
template<class
S
>
constexpr const Matrix33 &setShear
(const Vec2<S> &h) noexcept¶ Set matrix to shear x for each y coord.
by given factor h[0] and to shear y for each x coord. by given factor h[1]
- Return
const referenced to this
Numeric Limits
-
static inline constexpr static T baseTypeLowest () noexcept
Largest possible negative value.
-
static inline constexpr static T baseTypeMax () noexcept
Largest possible positive value.
-
static inline constexpr static T baseTypeSmallest () noexcept
Smallest possible positive value.
-
static inline constexpr static T baseTypeEpsilon () noexcept
Smallest possible e for which 1+e != 1.
Public Types
Public Functions
Public Static Functions
-
static inline constexpr static unsigned int dimensions () noexcept
Return the number of the row and column dimensions, i.e. 3.
-
inline