MeVisLab Toolbox Reference
Loading...
Searching...
No Matches
mlMatrix3.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2007, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_MATRIX3_H
14#define ML_MATRIX3_H
15
17
18// Include system independent file and project settings.
20#include "mlLinearAlgebraDefs.h"
22
24
25#include "mlMatrix2.h"
26#include "mlVector3.h"
27
28#include <cstdlib>
29// All declarations of this header will be in the ML_LA_NAMESPACE namespace.
31
32//--------------------------------------------------------------------
34//--------------------------------------------------------------------
35template <class DT> class Tmat3 : public FloatingPointMatrix<Tvec3<DT>, 3>
36{
37
38public:
40 typedef DT ComponentType;
41
44
46 Tmat3(const DT diagValue);
47
49 Tmat3(const Tvec3<DT>& row0, const Tvec3<DT>& row1, const Tvec3<DT>& row2);
50
53
55 Tmat3(const float mat[9]);
56
58 Tmat3(const double mat[9]);
59
62 Tmat3(const double in00, const double in01, const double in02, const double in10, const double in11,
63 const double in12, const double in20, const double in21, const double in22);
64
66 void setValues(const float mat[9]);
67
71 void getValues(float mat[9]) const;
72
74 void setValues(const double mat[9]);
75
77 void getValues(double mat[9]) const;
78
80 void setScaleMatrix(const DT scale);
81
83 static Tmat3<DT> getMat(const double val);
84
86 void set(DT val);
87
90 bool operator<(const Tmat3<DT>&) const
91 {
92 return false;
93 }
94
97
100
103
105 const Tmat3<DT>& operator*=(const DT d);
106
109 const Tmat3<DT>& operator/=(const DT d);
110
111 //-------------------------------------------------
112 // Special functions
113 //-------------------------------------------------
115 DT det() const;
116
119
122
130 Tmat3 inverse(bool* isInvertible = nullptr) const;
131
134
137
138}; // end of class *Tmat3*
139
140
141//---------------------------------------------------------------------
144//---------------------------------------------------------------------
146template <class DT> inline Tmat3<DT>::Tmat3()
147{
148 this->v[0] = this->v[1] = this->v[2] = Tvec3<DT>(0);
149}
150
152template <class DT> inline Tmat3<DT>::Tmat3(const DT diagValue)
153{
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;
157}
158
160template <class DT> inline Tmat3<DT>::Tmat3(const Tvec3<DT>& row0, const Tvec3<DT>& row1, const Tvec3<DT>& row2)
161{
162 this->v[0] = row0;
163 this->v[1] = row1;
164 this->v[2] = row2;
165}
166
168template <class DT> inline Tmat3<DT>::Tmat3(const Tmat3<DT>& mat)
169{
170 this->v[0] = mat.v[0];
171 this->v[1] = mat.v[1];
172 this->v[2] = mat.v[2];
173}
174
176template <class DT> inline Tmat3<DT>::Tmat3(const float mat[9])
177{
178 setValues(mat);
179}
180
182template <class DT> inline Tmat3<DT>::Tmat3(const double mat[9])
183{
184 setValues(mat);
185}
186
188template <class DT> inline Tmat3<DT> Tmat3<DT>::getMat(const double val)
189{
190 return Tmat3<DT>(val, val, val, val, val, val, val, val, val);
191}
192
194template <class DT> inline void Tmat3<DT>::set(DT val)
195{
196 this->v[0] = this->v[1] = this->v[2] = Tvec3<DT>(val);
197}
198
200template <class DT> inline const Tmat3<DT>& Tmat3<DT>::operator=(const Tmat3<DT>& m)
201{
202 if (&m != this) {
203 this->v[0] = m.v[0];
204 this->v[1] = m.v[1];
205 this->v[2] = m.v[2];
206 }
207
208 return *this;
209}
210
212template <class DT> inline const Tmat3<DT>& Tmat3<DT>::operator+=(const Tmat3<DT>& m)
213{
214 this->v[0] += m.v[0];
215 this->v[1] += m.v[1];
216 this->v[2] += m.v[2];
217
218 return *this;
219}
220
222template <class DT> inline const Tmat3<DT>& Tmat3<DT>::operator-=(const Tmat3<DT>& m)
223{
224 this->v[0] -= m.v[0];
225 this->v[1] -= m.v[1];
226 this->v[2] -= m.v[2];
227
228 return *this;
229}
230
232template <class DT> inline const Tmat3<DT>& Tmat3<DT>::operator*=(const DT d)
233{
234 this->v[0] *= d;
235 this->v[1] *= d;
236 this->v[2] *= d;
237
238 return *this;
239}
240
242template <class DT> inline const Tmat3<DT>& Tmat3<DT>::operator/=(const DT d)
243{
244 this->v[0] /= d;
245 this->v[1] /= d;
246 this->v[2] /= d;
247 return *this;
248}
250
251
252//====================================================================
255//====================================================================
257template <class DT> inline Tmat3<DT> operator-(const Tmat3<DT>& a)
258{
259 return Tmat3<DT>(a) *= static_cast<DT>(-1.0);
260}
261
263template <class DT> inline Tmat3<DT> operator+(const Tmat3<DT>& a, const Tmat3<DT>& b)
264{
265 return Tmat3<DT>(a) += b;
266}
267
269template <class DT> inline Tmat3<DT> operator-(const Tmat3<DT>& a, const Tmat3<DT>& b)
270{
271 return Tmat3<DT>(a) -= b;
272}
273
275template <class DT> inline Tmat3<DT> operator*(const Tmat3<DT>& a, const DT d)
276{
277 return Tmat3<DT>(a) *= d;
278}
279
281template <class DT> inline Tmat3<DT> operator*(const DT d, const Tmat3<DT>& a)
282{
283 return Tmat3<DT>(a) *= d;
284}
285
288template <class DT> inline Tmat3<DT> operator/(const Tmat3<DT>& a, const DT d)
289{
290 Tmat3<DT> retVal(a);
291 retVal /= d;
292 return retVal;
293}
295
296
297//-------------------------------------------------------------------
298//
301//
302//-------------------------------------------------------------------
303
304//-------------------------------------------------------------------
307//-------------------------------------------------------------------
308template <class DT> inline Tmat3<DT>::Tmat3(const double in00, const double in01, const double in02, const double in10,
309 const double in11, const double in12, const double in20, const double in21,
310 const double in22)
311{
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);
321}
322
323
324//--------------------------------------------------------------------
326//--------------------------------------------------------------------
327template <class DT> inline void Tmat3<DT>::setValues(const float mat[9])
328{
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]);
338}
339
340//--------------------------------------------------------------------
344//--------------------------------------------------------------------
345template <class DT> inline void Tmat3<DT>::getValues(float mat[9]) const
346{
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]);
356}
357
358//--------------------------------------------------------------------
360//--------------------------------------------------------------------
361template <class DT> inline void Tmat3<DT>::setValues(const double mat[9])
362{
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]);
372}
373
374//--------------------------------------------------------------------
378//--------------------------------------------------------------------
379template <class DT> inline void Tmat3<DT>::getValues(double mat[9]) const
380{
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]);
390}
391
392
393//-------------------------------------------------------------------
395//-------------------------------------------------------------------
396template <class DT> inline void Tmat3<DT>::setScaleMatrix(const DT scale)
397{
398 this->v[0][0] = scale;
399 this->v[0][1] = 0;
400 this->v[0][2] = 0;
401 this->v[1][0] = 0;
402 this->v[1][1] = scale;
403 this->v[1][2] = 0;
404 this->v[2][0] = 0;
405 this->v[2][1] = 0;
406 this->v[2][2] = scale;
407}
409
410
411//-------------------------------------------------------------------
414//-------------------------------------------------------------------
415
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))
418//-------------------------------------------------------------------
420//-------------------------------------------------------------------
421template <class DT> DT Tmat3<DT>::det() const
422{
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]);
425}
426#undef DET3
427
428//-------------------------------------------------------------------
430//-------------------------------------------------------------------
431template <class DT> inline Tmat3<DT> Tmat3<DT>::transpose() const
432{
433 return Tmat3<DT>(Tvec3<DT>(this->v[0][0], this->v[1][0], this->v[2][0]),
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]));
436}
437
438//-------------------------------------------------------------------
440//-------------------------------------------------------------------
441template <class DT> inline Tmat3<DT> Tmat3<DT>::getIdentity()
442{
443 return Tmat3<DT>(Tvec3<DT>(1, 0, 0), Tvec3<DT>(0, 1, 0), Tvec3<DT>(0, 0, 1));
444}
445
446//-------------------------------------------------------------------
448//-------------------------------------------------------------------
449template <class DT> inline const Tmat3<DT>& Tmat3<DT>::apply(MLDblFuncPtr fct)
450{
451 this->v[0].apply(fct);
452 this->v[1].apply(fct);
453 this->v[2].apply(fct);
454 return *this;
455}
456
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]
459//-------------------------------------------------------------------
461//-------------------------------------------------------------------
462template <class DT> inline Tmat3<DT> operator*(const Tmat3<DT>& a, const Tmat3<DT>& b)
463{
464 return Tmat3<DT>(Tvec3<DT>(_ML_MAT3_RC(0, 0), _ML_MAT3_RC(0, 1), _ML_MAT3_RC(0, 2)),
465 Tvec3<DT>(_ML_MAT3_RC(1, 0), _ML_MAT3_RC(1, 1), _ML_MAT3_RC(1, 2)),
466 Tvec3<DT>(_ML_MAT3_RC(2, 0), _ML_MAT3_RC(2, 1), _ML_MAT3_RC(2, 2)));
467}
468#undef _ML_MAT3_RC
469
470//-------------------------------------------------------------------
472//-------------------------------------------------------------------
473template <class DT> inline bool operator==(const Tmat3<DT>& a, const Tmat3<DT>& b)
474{
475 return (a[0] == b[0]) && (a[1] == b[1]) && (a[2] == b[2]);
476}
477
478//-------------------------------------------------------------------
480//-------------------------------------------------------------------
481template <class DT> inline bool operator!=(const Tmat3<DT>& a, const Tmat3<DT>& b)
482{
483 return !(a == b);
484}
485
486//-------------------------------------------------------------------
487//
488// Special global 2D functions and 3D functions
489//
490//-------------------------------------------------------------------
491
492//--------------------------------------------------------------------
495//--------------------------------------------------------------------
496template <class DT> Tmat3<DT> identity2D()
497{
498 return Tmat3<DT>::getIdentity();
499}
500
501//-------------------------------------------------------------------
504//-------------------------------------------------------------------
505template <class DT> inline Tmat3<DT> translation2D(const Tvec2<DT>& v)
506{
507 return Tmat3<DT>(Tvec3<DT>(1.0, 0.0, v[0]), Tvec3<DT>(0.0, 1.0, v[1]), Tvec3<DT>(0.0, 0.0, 1.0));
508}
509
510//-------------------------------------------------------------------
513//-------------------------------------------------------------------
514template <class DT> Tmat3<DT> rotation2D(const Tvec2<DT>& Center, const DT angleDeg)
515{
516 DT angleRad = angleDeg * M_PI / 180.0;
517 DT c = cos(angleRad);
518 DT s = sin(angleRad);
519
520 return Tmat3<DT>(Tvec3<DT>(c, -s, Center[0] * (1.0 - c) + Center[1] * s),
521 Tvec3<DT>(s, c, Center[1] * (1.0 - c) - Center[0] * s), Tvec3<DT>(0.0, 0.0, 1.0));
522}
523
524//-------------------------------------------------------------------
526//-------------------------------------------------------------------
527template <class DT> inline Tmat3<DT> scaling2D(const Tvec2<DT>& scaleVector)
528{
529 return Tmat3<DT>(Tvec3<DT>(scaleVector[0], 0.0, 0.0), Tvec3<DT>(0.0, scaleVector[1], 0.0), Tvec3<DT>(0.0, 0.0, 1.0));
530}
531
532
533//-------------------------------------------------------------------
545//-------------------------------------------------------------------
546template <class DT> Tmat3<DT> Tmat3<DT>::jacobi(Tvec3<DT>& evalues, int& rots) const
547{
548 Tmat3<DT> evectors(getIdentity());
549
550 // TODO: Further documentation of the algorithm required!
551
552 DT sm = 0; // smallest entry
553 DT theta = 0; // angle for Jacobi rotation
554 DT c = 0, s = 0, t = 0; // cosine, sine, tangent of theta
555 DT tau = 0; // sine / (1 + cos)
556 DT h = 0, g = 0; // two scrap values
557 DT thresh = 0; // threshold below which no rotation done
558
559 int p = 0, q = 0, i = 0, j = 0;
560
561 // Initialization
562 Tvec3<DT> b(this->v[0][0], this->v[1][1], this->v[2][2]); // diagonal elements
563 Tvec3<DT> z(0, 0, 0);
564 evalues = b;
565
566 Tmat3<DT> a(*this);
567
568 rots = 0;
569 for (i = 0; i < 50;
570 i++) { // typical matrices require 6 to 10 sweeps to achieve convergence - hence 50 gives some safety margin
571 sm = 0.0;
572 for (p = 0; p < 2; p++) {
573 for (q = p + 1; q < 3; q++) {
574 sm += std::abs(a.v[p][q]); // sum off-diagonal elements
575 }
576 }
577
578 if (sm == 0.0) {
579 return *(&evectors); // circumvent a code generation bug in Visual Studio 2019 (version 16.5.4)
580 }
581
582 thresh = (i < 3 ? (.2 * sm / 9) : 0.0);
583
584 for (p = 0; p < 2; p++) {
585 for (q = p + 1; q < 3; q++) { // compute on sweep, i.e. one rotation for each of-diagonal element of the matrix
586
587 g = 100.0 * std::abs(a.v[p][q]);
588
589 if ((i > 3) && (std::abs(evalues[p]) + g == std::abs(evalues[p])) &&
590 (std::abs(evalues[q]) + g == std::abs(evalues[q])))
591 {
592 a.v[p][q] = 0.0; // after three sweeps, skip rotation of small off diagonal elements
593 }
594 else if (std::abs(a.v[p][q]) > thresh) {
595 h = evalues[q] - evalues[p];
596 if (std::abs(h) + g == std::abs(h)) {
597 t = a.v[p][q] / h;
598 }
599 else {
600 theta = .5 * h / a.v[p][q];
601 t = 1.0 / (std::abs(theta) + sqrt(1 + theta * theta));
602 if (theta < 0.0) {
603 t = -t;
604 }
605 }
606 // End of computing tangent of rotation angle
607
608 c = 1.0 / sqrt(1.0 + t * t);
609 s = t * c;
610 tau = s / (1.0 + c);
611 h = t * a.v[p][q];
612 z[p] -= h;
613 z[q] += h;
614 evalues[p] -= h;
615 evalues[q] += h;
616 a.v[p][q] = 0.0;
617
618 for (j = 0; j < p; j++) {
619 g = a.v[j][p];
620 h = a.v[j][q];
621 a.v[j][p] = g - s * (h + g * tau);
622 a.v[j][q] = h + s * (g - h * tau);
623 }
624
625 for (j = p + 1; j < q; j++) {
626 g = a.v[p][j];
627 h = a.v[j][q];
628 a.v[p][j] = g - s * (h + g * tau);
629 a.v[j][q] = h + s * (g - h * tau);
630 }
631
632 for (j = q + 1; j < 3; j++) {
633 g = a.v[p][j];
634 h = a.v[q][j];
635 a.v[p][j] = g - s * (h + g * tau);
636 a.v[q][j] = h + s * (g - h * tau);
637 }
638
639 for (j = 0; j < 3; j++) {
640 g = evectors.v[j][p];
641 h = evectors.v[j][q];
642 evectors.v[j][p] = g - s * (h + g * tau);
643 evectors.v[j][q] = h + s * (g - h * tau);
644 }
645 } // else if (std::abs(a.v[p][q]) > thresh)
646
647 rots++;
648
649 } // for (q = p+1; q < 3; q++)
650 } // for (p = 0; p < 2; p++)
651
652 for (p = 0; p < 3; p++) {
653 evalues[p] = b[p] += z[p];
654 z[p] = 0;
655 }
656 } // for (i = 0; i < 50; i++)
657 return evectors;
658}
659
660//-------------------------------------------------------------------
668//-------------------------------------------------------------------
669template <class DT> Tmat3<DT> Tmat3<DT>::inverse(bool* isInvertible) const
670{
671 // Epsilon for comparison with 0 in inversion process.
672 static const DT Epsilon = static_cast<DT>(0.);
673
674 // Use helper function from tools to invert the matrix.
676 "Tmat3<DT> Tmat3<DT>::inverse(bool* isInvertible) const, matrix not invertable",
677 getIdentity(), 3);
678}
679
680//-----------------------------------------------------------------------------------
683//-----------------------------------------------------------------------------------
684
694
696
697namespace std
698{
699 //-------------------------------------------------------------------
701 //-------------------------------------------------------------------
702 template <class DT> inline std::ostream& operator<<(std::ostream& os, const ML_LA_NAMESPACE::Tmat3<DT>& m)
703 {
704 return os << m[0] << '\n' << m[1] << '\n' << m[2];
705 }
706
707 //-------------------------------------------------------------------
709 //-------------------------------------------------------------------
710 template <class DT> inline std::istream& operator>>(std::istream& is, ML_LA_NAMESPACE::Tmat3<DT>& m)
711 {
712 ML_LA_NAMESPACE::Tmat3<DT> m_tmp;
713
714 is >> m_tmp[0] >> m_tmp[1] >> m_tmp[2];
715 if (is) {
716 m = m_tmp;
717 }
718 return is;
719 }
720} // namespace std
721
722
723#endif // __mlMatrix3_H
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.
Definition mlMatrix3.h:36
bool operator<(const Tmat3< DT > &) const
Dummy 'lesser than operator' that always returns false.
Definition mlMatrix3.h:90
void setValues(const float mat[9])
Copies the contents from float array mat into *this, row by row.
Definition mlMatrix3.h:327
static Tmat3 getIdentity()
Returns the identity matrix.
Definition mlMatrix3.h:441
static Tmat3< DT > getMat(const double val)
Returns a matrix filled with values val.
Definition mlMatrix3.h:188
void setScaleMatrix(const DT scale)
Sets the diagonal matrix with scale on the diagonal.
Definition mlMatrix3.h:396
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.
Definition mlMatrix3.h:308
const Tmat3< DT > & operator+=(const Tmat3< DT > &m)
Increments by a Tmat3.
Definition mlMatrix3.h:212
Tmat3(const double mat[9])
Constructor from nine double values in an array given by mat, row by row.
Definition mlMatrix3.h:182
const Tmat3< DT > & operator-=(const Tmat3< DT > &m)
Decrements by a Tmat3.
Definition mlMatrix3.h:222
void getValues(float mat[9]) const
Copies the contents of *this into float array mat, row by row.
Definition mlMatrix3.h:345
const Tmat3< DT > & operator*=(const DT d)
Multiplies by a scalar constant d.
Definition mlMatrix3.h:232
void getValues(double mat[9]) const
Copies the contents of *this into double array mat, row by row.
Definition mlMatrix3.h:379
Tmat3 transpose() const
Returns the transpose of this matrix.
Definition mlMatrix3.h:431
Tmat3(const Tmat3< DT > &mat)
Copy constructor from the Tmat3 mat.
Definition mlMatrix3.h:168
Tmat3(const Tvec3< DT > &row0, const Tvec3< DT > &row1, const Tvec3< DT > &row2)
Builds a matrix of the three row vectors row0, row1, row2.
Definition mlMatrix3.h:160
Tmat3(const DT diagValue)
Builds a matrix that has the argument diagValue as the diagonal values, zero otherwise.
Definition mlMatrix3.h:152
DT ComponentType
A typedef to 'export' the type of components.
Definition mlMatrix3.h:40
const Tmat3< DT > & apply(MLDblFuncPtr fct)
Applies the function fct to each component.
Definition mlMatrix3.h:449
Tmat3(const float mat[9])
Constructor from nine floating point values in an array given by mat, row by row.
Definition mlMatrix3.h:176
void setValues(const double mat[9])
Copies the contents from double array mat into *this, row by row.
Definition mlMatrix3.h:361
Tmat3 jacobi(Tvec3< DT > &eVal, int &rots) const
Calculates the Jacobi-decomposition of 3x3 matrix.
Definition mlMatrix3.h:546
Tmat3()
Builds a 3x3 matrix from nine zero elements.
Definition mlMatrix3.h:146
Tmat3 inverse(bool *isInvertible=nullptr) const
Returns the inverse.
Definition mlMatrix3.h:669
const Tmat3< DT > & operator=(const Tmat3< DT > &m)
Assigns from a Tmat3.
Definition mlMatrix3.h:200
const Tmat3< DT > & operator/=(const DT d)
Divides by a scalar constant.
Definition mlMatrix3.h:242
void set(DT val)
Sets all values to val.
Definition mlMatrix3.h:194
DT det() const
Returns the determinant of this matrix.
Definition mlMatrix3.h:421
Declaration of float vector type traits.
Definition mlVector2.h:57
Forward declarations to resolve header file dependencies.
Definition mlVector3.h:66
#define DET3(A, B, C, D, E, F, G, H, I)
Internal helper macro to calculate the determinant of 3x3 matrix with given entries,...
Definition mlMatrix3.h:417
#define _ML_MAT3_RC(i, j)
Internal helper macro to multiply two matrices, do not use.
Definition mlMatrix3.h:458
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.
double sqrt(T value)
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.
Definition mlMatrix2.h:399
Tmat3< DT > translation2D(const Tvec2< DT > &v)
Returns a 2D translation matrix as 3D homogeneous matrix where the translation is located in the righ...
Definition mlMatrix3.h:505
Tmat3< DT > identity2D()
Returns a 3x3 homogeneous identity2D matrix; synonym for Tmat3<DT>::getIdentity().
Definition mlMatrix3.h:496
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.
Definition mlMatrix3.h:514
bool operator!=(const Tmat2< DT > &a, const Tmat2< DT > &b)
a != b ? Returns true if yes.
Definition mlMatrix2.h:405
Tmat3< DT > scaling2D(const Tvec2< DT > &scaleVector)
Returns a 2D scale matrix as 3D homogeneous matrix.
Definition mlMatrix3.h:527
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.
STL namespace.
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.