148 this->v[0] = this->v[1] = this->v[2] =
Tvec3<DT>(0);
154 this->v[0][0] = this->v[1][1] = this->v[2][2] =
diagValue;
155 this->v[1][0] = this->v[2][0] = this->v[2][1] = 0;
156 this->v[0][1] = this->v[0][2] = this->v[1][2] = 0;
170 this->v[0] =
mat.
v[0];
171 this->v[1] =
mat.v[1];
172 this->v[2] =
mat.v[2];
190 return Tmat3<DT>(val, val, val, val, val, val, val, val, val);
196 this->v[0] = this->v[1] = this->v[2] =
Tvec3<DT>(val);
214 this->v[0] +=
m.
v[0];
215 this->v[1] +=
m.v[1];
216 this->v[2] +=
m.v[2];
224 this->v[0] -=
m.
v[0];
225 this->v[1] -=
m.v[1];
226 this->v[2] -=
m.v[2];
259 return Tmat3<DT>(a) *=
static_cast<DT
>(-1.0);
312 this->v[0][0] =
static_cast<DT
>(
in00);
313 this->v[0][1] =
static_cast<DT
>(
in01);
314 this->v[0][2] =
static_cast<DT
>(
in02);
315 this->v[1][0] =
static_cast<DT
>(
in10);
316 this->v[1][1] =
static_cast<DT
>(
in11);
317 this->v[1][2] =
static_cast<DT
>(
in12);
318 this->v[2][0] =
static_cast<DT
>(
in20);
319 this->v[2][1] =
static_cast<DT
>(
in21);
320 this->v[2][2] =
static_cast<DT
>(
in22);
329 this->v[0][0] =
static_cast<DT
>(
mat[0]);
330 this->v[0][1] =
static_cast<DT
>(
mat[1]);
331 this->v[0][2] =
static_cast<DT
>(
mat[2]);
332 this->v[1][0] =
static_cast<DT
>(
mat[3]);
333 this->v[1][1] =
static_cast<DT
>(
mat[4]);
334 this->v[1][2] =
static_cast<DT
>(
mat[5]);
335 this->v[2][0] =
static_cast<DT
>(
mat[6]);
336 this->v[2][1] =
static_cast<DT
>(
mat[7]);
337 this->v[2][2] =
static_cast<DT
>(
mat[8]);
347 mat[0] =
static_cast<float>(this->v[0][0]);
348 mat[1] =
static_cast<float>(this->v[0][1]);
349 mat[2] =
static_cast<float>(this->v[0][2]);
350 mat[3] =
static_cast<float>(this->v[1][0]);
351 mat[4] =
static_cast<float>(this->v[1][1]);
352 mat[5] =
static_cast<float>(this->v[1][2]);
353 mat[6] =
static_cast<float>(this->v[2][0]);
354 mat[7] =
static_cast<float>(this->v[2][1]);
355 mat[8] =
static_cast<float>(this->v[2][2]);
363 this->v[0][0] =
static_cast<DT
>(
mat[0]);
364 this->v[0][1] =
static_cast<DT
>(
mat[1]);
365 this->v[0][2] =
static_cast<DT
>(
mat[2]);
366 this->v[1][0] =
static_cast<DT
>(
mat[3]);
367 this->v[1][1] =
static_cast<DT
>(
mat[4]);
368 this->v[1][2] =
static_cast<DT
>(
mat[5]);
369 this->v[2][0] =
static_cast<DT
>(
mat[6]);
370 this->v[2][1] =
static_cast<DT
>(
mat[7]);
371 this->v[2][2] =
static_cast<DT
>(
mat[8]);
381 mat[0] =
static_cast<double>(this->v[0][0]);
382 mat[1] =
static_cast<double>(this->v[0][1]);
383 mat[2] =
static_cast<double>(this->v[0][2]);
384 mat[3] =
static_cast<double>(this->v[1][0]);
385 mat[4] =
static_cast<double>(this->v[1][1]);
386 mat[5] =
static_cast<double>(this->v[1][2]);
387 mat[6] =
static_cast<double>(this->v[2][0]);
388 mat[7] =
static_cast<double>(this->v[2][1]);
389 mat[8] =
static_cast<double>(this->v[2][2]);
398 this->v[0][0] = scale;
402 this->v[1][1] = scale;
406 this->v[2][2] = scale;
417#define DET3(A, B, C, D, E, F, G, H, I) ((A * E * I + B * F * G + C * D * H) - (A * F * H + B * D * I + C * E * G))
423 return DET3(this->v[0][0], this->v[0][1], this->v[0][2], this->v[1][0], this->v[1][1], this->v[1][2], this->v[2][0],
424 this->v[2][1], this->v[2][2]);
434 Tvec3<DT>(this->v[0][1], this->v[1][1], this->v[2][1]),
435 Tvec3<DT>(this->v[0][2], this->v[1][2], this->v[2][2]));
452 this->v[1].apply(
fct);
453 this->v[2].apply(
fct);
458#define _ML_MAT3_RC(i, j) a[i][0] * b[0][j] + a[i][1] * b[1][j] + a[i][2] * b[2][j]
475 return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]);
554 DT c = 0, s = 0, t = 0;
559 int p = 0,
q = 0,
i = 0,
j = 0;
562 Tvec3<DT> b(this->v[0][0], this->v[1][1], this->v[2][2]);
572 for (p = 0; p < 2; p++) {
573 for (
q = p + 1;
q < 3;
q++) {
574 sm += std::abs(a.
v[p][
q]);
584 for (p = 0; p < 2; p++) {
585 for (
q = p + 1;
q < 3;
q++) {
587 g = 100.0 * std::abs(a.
v[p][
q]);
594 else if (std::abs(a.
v[p][
q]) >
thresh) {
596 if (std::abs(h) + g == std::abs(h)) {
608 c = 1.0 /
sqrt(1.0 + t * t);
618 for (
j = 0;
j < p;
j++) {
621 a.
v[
j][p] = g - s * (h + g *
tau);
622 a.
v[
j][
q] = h + s * (g - h *
tau);
625 for (
j = p + 1;
j <
q;
j++) {
628 a.
v[p][
j] = g - s * (h + g *
tau);
629 a.
v[
j][
q] = h + s * (g - h *
tau);
632 for (
j =
q + 1;
j < 3;
j++) {
635 a.
v[p][
j] = g - s * (h + g *
tau);
636 a.
v[
q][
j] = h + s * (g - h *
tau);
639 for (
j = 0;
j < 3;
j++) {
652 for (p = 0; p < 3; p++) {
672 static const DT
Epsilon =
static_cast<DT
>(0.);
676 "Tmat3<DT> Tmat3<DT>::inverse(bool* isInvertible) const, matrix not invertable",
702 template <
class DT>
inline std::ostream&
operator<<(std::ostream&
os,
const ML_LA_NAMESPACE::Tmat3<DT>&
m)
704 return os <<
m[0] <<
'\n' <<
m[1] <<
'\n' <<
m[2];
710 template <
class DT>
inline std::istream&
operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat3<DT>&
m)
712 ML_LA_NAMESPACE::Tmat3<DT>
m_tmp;
Base class of all matrix classes that holds the data buffer and provides some general access methods.
VectorT v[size]
The rows constituting the matrix.
A 3x3 matrix class of three row vectors.
bool operator<(const Tmat3< DT > &) const
Dummy 'lesser than operator' that always returns false.
void setValues(const float mat[9])
Copies the contents from float array mat into *this, row by row.
static Tmat3 getIdentity()
Returns the identity matrix.
static Tmat3< DT > getMat(const double val)
Returns a matrix filled with values val.
void setScaleMatrix(const DT scale)
Sets the diagonal matrix with scale on the diagonal.
Tmat3(const double in00, const double in01, const double in02, const double in10, const double in11, const double in12, const double in20, const double in21, const double in22)
Initializes all matrix elements explicitly with scalars, filling it row by row.
const Tmat3< DT > & operator+=(const Tmat3< DT > &m)
Increments by a Tmat3.
Tmat3(const double mat[9])
Constructor from nine double values in an array given by mat, row by row.
const Tmat3< DT > & operator-=(const Tmat3< DT > &m)
Decrements by a Tmat3.
void getValues(float mat[9]) const
Copies the contents of *this into float array mat, row by row.
const Tmat3< DT > & operator*=(const DT d)
Multiplies by a scalar constant d.
void getValues(double mat[9]) const
Copies the contents of *this into double array mat, row by row.
Tmat3 transpose() const
Returns the transpose of this matrix.
Tmat3(const Tmat3< DT > &mat)
Copy constructor from the Tmat3 mat.
Tmat3(const Tvec3< DT > &row0, const Tvec3< DT > &row1, const Tvec3< DT > &row2)
Builds a matrix of the three row vectors row0, row1, row2.
Tmat3(const DT diagValue)
Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.
DT ComponentType
A typedef to 'export' the type of components.
const Tmat3< DT > & apply(MLDblFuncPtr fct)
Applies the function fct to each component.
Tmat3(const float mat[9])
Constructor from nine floating point values in an array given by mat, row by row.
void setValues(const double mat[9])
Copies the contents from double array mat into *this, row by row.
Tmat3 jacobi(Tvec3< DT > &eVal, int &rots) const
Calculates the Jacobi-decomposition of 3x3 matrix.
Tmat3()
Builds a 3x3 matrix from nine zero elements.
Tmat3 inverse(bool *isInvertible=nullptr) const
Returns the inverse.
const Tmat3< DT > & operator=(const Tmat3< DT > &m)
Assigns from a Tmat3.
const Tmat3< DT > & operator/=(const DT d)
Divides by a scalar constant.
void set(DT val)
Sets all values to val.
DT det() const
Returns the determinant of this matrix.
Declaration of float vector type traits.
Forward declarations to resolve header file dependencies.
#define DET3(A, B, C, D, E, F, G, H, I)
Internal helper macro to calculate the determinant of 3x3 matrix with given entries,...
#define _ML_MAT3_RC(i, j)
Internal helper macro to multiply two matrices, do not use.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
double(* MLDblFuncPtr)(double)
A function pointer type to a function that returns a double and takes a double as argument.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component-wise division of lhs by specialized rhs of type MLdouble.
bool operator==(const Tmat2< DT > &a, const Tmat2< DT > &b)
a == b ? Returns true if yes.
Tmat3< DT > translation2D(const Tvec2< DT > &v)
Returns a 2D translation matrix as 3D homogeneous matrix where the translation is located in the righ...
Tmat3< DT > identity2D()
Returns a 3x3 homogeneous identity2D matrix; synonym for Tmat3<DT>::getIdentity().
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
Tmat3< DT > rotation2D(const Tvec2< DT > &Center, const DT angleDeg)
Returns a 2D rotation matrix as 3D homogeneous matrix where center specifies the center of rotation.
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Returns true if yes.
Tmat3< DT > scaling2D(const Tvec2< DT > &scaleVector)
Returns a 2D scale matrix as 3D homogeneous matrix.
FloatingPointVector< T, size, DataContainer > operator-(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component-wise subtraction of rhs from lhs.
BASE_TYPE MLInverseMatHelper(const BASE_TYPE &origMat, bool *isInvertible, const typename BASE_TYPE::ComponentType, const char *const ZeroDetErrString, const BASE_TYPE &Identity, const size_t Dim)
Computes an N dimensional inverse from given default parameters.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
istream & operator>>(istream &is, ml::FloatingPointVector< T, size, DataContainer > &v)
Reads a vector from std::istream.