Matrix22¶
The Matrix22 class template represents a 2x2 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
matrix22_example()
{
Imath::M22f M (Imath::UNINITIALIZED); // uninitialized
M.makeIdentity();
assert (M[0][0] == 1.0f);
assert (M[0][1] == 0.0f);
Imath::M22f Minv = M.inverse();
Imath::M22f R;
assert (R == Imath::identity22f);
R.rotate (M_PI/4);
M = R * M;
Imath::V2f v2 (1.0f, 0.0f);
Imath::V2f r2 = v2 * M;
assert (r2.equalWithAbsError (Imath::V2f (0.707107f, 0.707107f), 1e-6f));
}
-
template <class T>
classMatrix22¶ 2x2 transformation matrix
Direct access to elements
-
template<>
Tx[2][2]¶ Matrix elements.
Constructors and Assignment
-
Matrix22(Uninitialized)¶ Uninitialized.
-
constexpr
Matrix22()¶ Default constructor: initialize to identity.
1 0 0 1
-
constexpr
Matrix22(T a)¶ Initialize to scalar constant:
a a a a
-
constexpr
Matrix22(const T a[2][2])¶ Construct from 2x2 array:
a[0][0] a[0][1] a[1][0] a[1][1]
-
constexpr
Matrix22(T a, T b, T c, T d)¶ Construct from given scalar values:
a b c d
-
template <class S>
constexprMatrix22(const Matrix22<S> &v)¶ Construct from Matrix22 of another base type.
-
~Matrix22()¶ Destructor.
Compatibility with Sb
-
T *
getValue()¶ Return a raw pointer to the array of values.
-
const T *
getValue() const¶ Return a raw pointer to the array of values.
Arithmetic and Comparison
-
constexpr bool
equalWithAbsError(const Matrix22<T> &v, T e) const¶ Compare two matrices and test if they are “approximately equal”:
- Return
- True if the coefficients of this and
mare 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
Maniplation
-
void
makeIdentity()¶ Set to the identity.
-
constexpr const Matrix22<T> &
invert(bool singExc)¶ Invert in place.
- Return
- const reference to this
- Parameters
singExc: If true, throw an exception if the matrix cannot be inverted.
-
constexpr Matrix22<T>
inverse(bool singExc) const¶ Return the inverse, leaving this unmodified.
- Parameters
singExc: If true, throw an exception if the matrix cannot be inverted.
-
constexpr T
determinant() const¶ Determinant.
-
template <class S>
const Matrix22 &setRotation(S r)¶ Set matrix to rotation by r (in radians)
- Return
- const referenced to this
-
template <class S>
constexpr const Matrix22 &rotate(S r)¶ Rotate the given matrix by r (in radians)
- Return
- const referenced to this
-
constexpr const Matrix22<T> &
setScale(T s)¶ Set matrix to scale by given uniform factor.
- Return
- const referenced to this
Numeric Limits
-
static constexpr T
baseTypeLowest()¶ Largest possible negative value.
-
static constexpr T
baseTypeMax()¶ Largest possible positive value.
-
static constexpr T
baseTypeSmallest()¶ Smallest possible positive value.
-
static constexpr T
baseTypeEpsilon()¶ Smallest possible e for which 1+e != 1.
Public Types
-
typedef T
BaseType¶ The base type: In templates that accept a parameter
V, you can refer toTasV::BaseType
Public Functions
-
T *
operator[](int i)¶ Row access.
-
const T *
operator[](int i) const¶ Row access.
-
template <class S>
const Matrix22<T> &setRotation(S r)
-
template <class S>
constexpr const Matrix22<T> &rotate(S r)
Public Static Functions
-
static constexpr unsigned int
dimensions()¶ Return the number of the row and column dimensions, i.e. 2.
-
template<>
Warning
doxygenfunction: Unable to resolve multiple matches for function “operator<<” with arguments (std::ostream& s, const Matrix22<T>& m) in doxygen xml output for project “Imath” from directory: doxyxml/. Potential matches:
- std::ostream &operator<<(std::ostream&, Imath::half)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Color4<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Euler<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Interval<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Line3<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix22<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix33<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Matrix44<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Plane3<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Quat<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Shear6<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec2<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec3<T>&)
- template <class T>
std::ostream &Imath::operator<<(std::ostream&, const Vec4<T>&)