64 Tmat3(
const double in00,
const double in01,
const double in02,
65 const double in10,
const double in11,
const double in12,
66 const double in20,
const double in21,
const double in22);
150 this->v[0] = this->v[1] = this->v[2] =
Tvec3<DT>(0);
157 this->v[0][0] = this->v[1][1] = this->v[2][2] = diagValue;
158 this->v[1][0] = this->v[2][0] = this->v[2][1] = 0;
159 this->v[0][1] = this->v[0][2] = this->v[1][2] = 0;
175 this->v[0] = mat.
v[0];
176 this->v[1] = mat.
v[1];
177 this->v[2] = mat.
v[2];
207 this->v[0] = this->v[1] = this->v[2] =
Tvec3<DT>(val);
227 this->v[0] += m.
v[0];
228 this->v[1] += m.
v[1];
229 this->v[2] += m.
v[2];
238 this->v[0] -= m.
v[0];
239 this->v[1] -= m.
v[1];
240 this->v[2] -= m.
v[2];
332 const double in10,
const double in11,
const double in12,
333 const double in20,
const double in21,
const double in22)
335 this->v[0][0]=
static_cast<DT>(in00); this->v[0][1]=
static_cast<DT>(in01); this->v[0][2]=
static_cast<DT>(in02);
336 this->v[1][0]=
static_cast<DT>(in10); this->v[1][1]=
static_cast<DT>(in11); this->v[1][2]=
static_cast<DT>(in12);
337 this->v[2][0]=
static_cast<DT>(in20); this->v[2][1]=
static_cast<DT>(in21); this->v[2][2]=
static_cast<DT>(in22);
347 this->v[0][0] =
static_cast<DT>(mat[0]); this->v[0][1] =
static_cast<DT>(mat[1]); this->v[0][2] =
static_cast<DT>(mat[2]);
348 this->v[1][0] =
static_cast<DT>(mat[3]); this->v[1][1] =
static_cast<DT>(mat[4]); this->v[1][2] =
static_cast<DT>(mat[5]);
349 this->v[2][0] =
static_cast<DT>(mat[6]); this->v[2][1] =
static_cast<DT>(mat[7]); this->v[2][2] =
static_cast<DT>(mat[8]);
360 mat[0] =
static_cast<float>(this->v[0][0]); mat[1] =
static_cast<float>(this->v[0][1]); mat[2] =
static_cast<float>(this->v[0][2]);
361 mat[3] =
static_cast<float>(this->v[1][0]); mat[4] =
static_cast<float>(this->v[1][1]); mat[5] =
static_cast<float>(this->v[1][2]);
362 mat[6] =
static_cast<float>(this->v[2][0]); mat[7] =
static_cast<float>(this->v[2][1]); mat[8] =
static_cast<float>(this->v[2][2]);
371 this->v[0][0] =
static_cast<DT>(mat[0]); this->v[0][1] =
static_cast<DT>(mat[1]); this->v[0][2] =
static_cast<DT>(mat[2]);
372 this->v[1][0] =
static_cast<DT>(mat[3]); this->v[1][1] =
static_cast<DT>(mat[4]); this->v[1][2] =
static_cast<DT>(mat[5]);
373 this->v[2][0] =
static_cast<DT>(mat[6]); this->v[2][1] =
static_cast<DT>(mat[7]); this->v[2][2] =
static_cast<DT>(mat[8]);
384 mat[0] =
static_cast<double>(this->v[0][0]); mat[1] =
static_cast<double>(this->v[0][1]); mat[2] =
static_cast<double>(this->v[0][2]);
385 mat[3] =
static_cast<double>(this->v[1][0]); mat[4] =
static_cast<double>(this->v[1][1]); mat[5] =
static_cast<double>(this->v[1][2]);
386 mat[6] =
static_cast<double>(this->v[2][0]); mat[7] =
static_cast<double>(this->v[2][1]); mat[8] =
static_cast<double>(this->v[2][2]);
396 this->v[0][0]=scale; this->v[0][1]=0; this->v[0][2]=0;
397 this->v[1][0]=0; this->v[1][1]=scale; this->v[1][2]=0;
398 this->v[2][0]=0; this->v[2][1]=0; this->v[2][2]=scale;
409 #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))
416 return DET3(this->v[0][0], this->v[0][1], this->v[0][2],
417 this->v[1][0], this->v[1][1], this->v[1][2],
418 this->v[2][0], this->v[2][1], this->v[2][2]);
429 Tvec3<DT>(this->v[0][1], this->v[1][1], this->v[2][1]),
430 Tvec3<DT>(this->v[0][2], this->v[1][2], this->v[2][2]));
450 this->v[0].apply(fct);
451 this->v[1].apply(fct);
452 this->v[2].apply(fct);
457 #define _ML_MAT3_RC(i, j) a[i][0]*b[0][j] + a[i][1]*b[1][j] + a[i][2]*b[2][j]
477 return (a[0] == b[0]) &&
526 DT angleRad = angleDeg * M_PI / 180.0;
527 DT c = cos(angleRad);
528 DT s = sin(angleRad);
531 Tvec3<DT>(s, c, Center[1] * (1.0-c) - Center[0] * s),
570 DT c = 0, s = 0, t = 0;
575 int p = 0, q = 0, i = 0, j = 0;
578 Tvec3<DT> b (this->v[0][0], this->v[1][1], this->v[2][2]);
585 for (i = 0; i < 50; i++){
587 for (p = 0; p < 2; p++){
588 for (q = p+1; q < 3; q++){
597 thresh = (i < 3 ? (.2 * sm / 9) : 0.0);
599 for (p = 0; p < 2; p++) {
600 for (q = p+1; q < 3; q++) {
610 h = evalues[q] - evalues[p];
615 theta = .5 * h / a.
v[p][q];
616 t = 1.0 / (
std::abs(theta) + sqrt(1 + theta * theta));
623 c = 1.0 / sqrt(1.0 + t*t);
633 for (j = 0; j < p; j++) {
636 a.
v[j][p] = g - s * (h + g * tau);
637 a.
v[j][q] = h + s * (g - h * tau);
640 for (j = p+1; j < q; j++) {
643 a.
v[p][j] = g - s * (h + g * tau);
644 a.
v[j][q] = h + s * (g - h * tau);
647 for (j = q+1; j < 3; j++) {
650 a.
v[p][j] = g - s * (h + g * tau);
651 a.
v[q][j] = h + s * (g - h * tau);
654 for (j = 0; j < 3; j++) {
655 g = evectors.
v[j][p];
656 h = evectors.
v[j][q];
657 evectors.
v[j][p] = g - s * (h + g * tau);
658 evectors.
v[j][q] = h + s * (g - h * tau);
667 for (p = 0; p < 3; p++) {
668 evalues[p] = b[p] += z[p];
688 static const DT Epsilon =
static_cast<DT>(0.);
694 "Tmat3<DT> Tmat3<DT>::inverse(bool* isInvertible) const, matrix not invertable",
722 inline std::ostream &
operator<<(std::ostream &os,
const ML_LA_NAMESPACE::Tmat3<DT> &m)
724 return os << m[0] <<
'\n' << m[1] <<
'\n' << m[2];
731 inline std::istream &
operator>>(std::istream &
is, ML_LA_NAMESPACE::Tmat3<DT> &m)
733 ML_LA_NAMESPACE::Tmat3<DT> m_tmp;
735 is >> m_tmp[0] >> m_tmp[1] >> m_tmp[2];
736 if (
is){ m = 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.
FloatingPointVector< T, size, DataContainer > operator/(FloatingPointVector< T, size, DataContainer > lhs, MLdouble rhs)
Component-wise division of lhs by specialized rhs of type MLdouble.
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
FloatingPointVector< T, size, DataContainer > operator+(FloatingPointVector< T, size, DataContainer > lhs, const FloatingPointVector< T, size, DataContainer > &rhs)
Return value is the component-wise addition of lhs and rhs.
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.
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.
MLEXPORT std::ostream & operator<<(std::ostream &s, const ml::Field &v)
Overloads the operator '<<' for stream output of Field objects.
#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.
double(* MLDblFuncPtr)(double)
A function pointer type to a function that returns a double and takes a double as argument.
std::istream & operator>>(std::istream &in, ml::Variant &variant)
void apply(Fnc &&fnc, const std::tuple< Args... > &tuple)
Tmat3< MLfloat > Matrix3f
A 3x3 matrix of type float.
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 > 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 Tmat3< DT > &a, const Tmat3< DT > &b)
a == b ? Return true if yes; otherwise, it returns false.
FloatingPointVector< T, size, DataContainer > & operator/=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component-wise division of *this by scalar value.
FloatingPointVector< T, size, DataContainer > & operator-=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component-wise subtraction of buffer from *this.
Tmat3< MLdouble > Matrix3
The standard 3x3 matrix of type double.
Tmat3< DT > scaling2D(const Tvec2< DT > &scaleVector)
Returns a 2D scale matrix as 3D homogeneous matrix.
Tmat3< MLldouble > Matrix3ld
A 3x3 matrix of type long double.
constexpr Is< T > is(T d)
Tmat3< MLdouble > Matrix3d
A 3x3 matrix of type double.
FloatingPointVector< T, size, DataContainer > & operator+=(FloatingPointVector< T, size, DataContainer > &op1, const FloatingPointVector< T, size, DataContainer > &buffer)
Arithmetic assignment: Component-wise addition.
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.
Tmat3< DT > identity2D()
Returns a 3x3 homogeneous identity2D matrix; synonym for Tmat3<DT>::getIdentity().
bool operator!=(const Tmat3< DT > &a, const Tmat3< DT > &b)
a != b ? Return true if yes; otherwise, it returns false.
FloatingPointVector< T, size, DataContainer > & operator*=(FloatingPointVector< T, size, DataContainer > &op1, MLdouble value)
Arithmetic assignment: Component-wise multiplication *this with specialized MLdouble scalar value.