Go to the documentation of this file. 1 #ifndef GfxTL__MATRIXX_HEADER__
2 #define GfxTL__MATRIXX_HEADER__
3 #ifndef _USE_MATH_DEFINES
4 #define _USE_MATH_DEFINES
23 template <
unsigned int D,
class T>
27 template <
unsigned int C,
unsigned int R,
class T>
31 template <
unsigned int C,
unsigned int R,
class T>
33 template <
unsigned int C,
unsigned int R,
class T>
35 template <
unsigned int C,
unsigned int R,
class T>
37 template <
unsigned int C,
unsigned int R,
class T>
39 template <
unsigned int C,
unsigned int R,
class T>
41 template <
unsigned int C,
unsigned int R,
class T>
43 template <
unsigned int C,
unsigned int R,
class T>
49 template <
unsigned int C,
unsigned int R,
class T>
79 memset(
_m, 0,
sizeof(
_m));
98 for (
unsigned int i = 0; i < C * R; ++i)
107 for (
unsigned int i = 0; i < C * R; ++i)
117 for (
unsigned int c = 0;
c < C; ++
c)
118 for (
unsigned int r = 0; r < R; ++r)
120 (*t)[r][
c] = (*this)[
c][r];
130 template <
unsigned int C,
unsigned int R,
class T>
230 template <
unsigned int A,
unsigned int B>
237 Error_InvalidDimension();
244 template <
unsigned int A>
303 operator const T()
const
315 template <
unsigned int C,
unsigned int R,
class T>
316 inline MatrixXX<C, R, T>&
319 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
321 m.Data()[i] += b.Data()[i];
326 template <
unsigned int C,
unsigned int R,
class T>
327 inline MatrixXX<C, R, T>&
330 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
332 m.Data()[i] -= b.Data()[i];
337 template <
unsigned int C,
unsigned int R,
class T>
338 inline MatrixXX<C, R, T>&
345 template <
unsigned int C,
unsigned int R,
class T>
346 inline MatrixXX<C, R, T>&
349 return m *= (
const T)b;
352 template <
unsigned int C,
unsigned int R,
class T>
353 inline MatrixXX<C, R, T>&
356 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
363 template <
unsigned int C,
unsigned int R,
class T>
364 inline MatrixXX<C, R, T>&
367 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
374 template <
unsigned int C,
unsigned int R,
class T>
375 inline MatrixXX<C, R, T>
379 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
386 template <
unsigned int C,
unsigned int R,
class T>
390 return memcmp(
a.Data(), b.Data(),
sizeof(
a)) == 0;
393 template <
unsigned int C,
unsigned int R,
class T>
397 return memcmp(
a.Data(), b.Data(),
sizeof(
a)) != 0;
400 template <
unsigned int C,
unsigned int R,
class T>
401 inline const MatrixXX<C, R, T>
409 template <
unsigned int C,
unsigned int R,
class T>
410 inline const MatrixXX<C, R, T>
416 template <
unsigned int C,
unsigned int R,
class T>
417 inline const MatrixXX<C, R, T>
426 template <
unsigned int C,
unsigned int R,
unsigned int C2,
class T>
427 inline const MatrixXX<C2, R, T>
431 for (
int c = 0;
c < C2; ++
c)
433 for (
int r = 0; r < R; ++r)
435 x[
c][r] =
a[0][r] * b[
c][0];
436 for (
int i = 1; i < C; ++i)
438 x[
c][r] +=
a[i][r] * b[
c][i];
445 template <
unsigned int C,
unsigned int R,
class T>
446 inline const MatrixXX<C, R, T>
449 return ((
const T)
a) * b;
452 template <
unsigned int C,
unsigned int R,
class T>
453 inline const MatrixXX<C, R, T>
457 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
459 c.Data()[i] =
a.Data()[i] + b.Data()[i];
464 template <
unsigned int C,
unsigned int R,
class T>
465 inline const MatrixXX<C, R, T>
469 for (
unsigned int i = 0; i < MatrixXX<C, R, T>::Entries; ++i)
471 c.Data()[i] =
a.Data()[i] - b.Data()[i];
476 template <
unsigned int N,
class T>
481 for (
unsigned int i = 0; i < N; ++i)
488 template <
unsigned int N,
class T>
493 for (
unsigned int i = 0; i < N; ++i)
510 template <
unsigned int N,
class T>
516 for (
unsigned int i = 0; i < N; ++i, j *= -1)
519 for (
unsigned int k = 1, kk = 0; kk < N - 1; ++kk, ++k)
521 for (
unsigned int l = 0, ll = 0; ll < N - 1; ++ll, ++l)
539 return a[0][0] * (
a[1][1] *
a[2][2] -
a[1][2] *
a[2][1]) -
540 a[0][1] * (
a[1][0] *
a[2][2] -
a[1][2] *
a[2][0]) +
541 a[0][2] * (
a[1][0] *
a[2][1] -
a[1][1] *
a[2][0]);
548 return a[0][0] *
a[1][1] -
a[1][0] *
a[0][1];
562 (*a)[0][0] = std::cos(rad);
563 (*a)[0][1] = std::sin(rad);
564 (*a)[1][0] = -(*a)[0][1];
565 (*a)[1][1] = (*a)[0][0];
568 template <
unsigned int N,
class T>
572 for (
unsigned int c = 0;
c < N; ++
c)
580 for (++r; r < N; ++r)
587 template <
unsigned int N,
class T>
597 template <
unsigned int C,
unsigned int R,
class T>
602 for (
unsigned int i = 0; i < C; ++i)
614 template <
unsigned int C,
unsigned int R,
class T>
615 inline MatrixXX<C, R, T>
620 for (
unsigned int c = 0;
c < C; ++
c)
621 for (
unsigned int r = 0; r < R; ++r)
623 m[
c][r] =
min(
a[
c][r], b[
c][r]);
628 template <
unsigned int C,
unsigned int R,
class T>
629 inline MatrixXX<C, R, T>
634 for (
unsigned int c = 0;
c < C; ++
c)
635 for (
unsigned int r = 0; r < R; ++r)
637 m[
c][r] =
max(
a[
c][r], b[
c][r]);
ThisType & operator=(const ThisType &v)
MatrixXX< 1, 1, T > ThisType
MatrixXX(const MatrixXX< 1, 1, T > &mat)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b, const MatrixXX< 1, R, T > &c, const MatrixXX< 1, R, T > &d)
MatrixXX< 4, 4, float > Matrix4f
MatrixXX< 1, 1, T > TransposedType
MatrixXX< C, R, T > ThisType
MatrixXX(const SuperType &mat)
MatrixXX< C, R, T > max(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< C, R, T > & ComponentMul(const MatrixXX< C, R, T > &a)
ThisType & operator=(T v)
bool operator==(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< C, R, T > & operator/=(MatrixXX< C, R, T > &m, T s)
MatrixXX< C, R, T > & operator*=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
static void AssertEqual()
MatrixXX< C, R, T > & operator+=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
Internal::BaseMatrixXX< 1, 1, T > SuperType
Matrix in column major order.
Internal::BaseMatrixXX< C, R, T > SuperType
void Identity(MatrixXX< N, N, T > *a)
double a(double t, double a0, double j)
std::ostream & operator<<(std::ostream &o, const Array< DimT, IteratorT > &a)
bool operator!=(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< 2, 2, float > Matrix2f
MatrixXX< C, R, T > operator-(const MatrixXX< C, R, T > &a)
ThisType & operator=(T v)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b, const MatrixXX< 1, R, T > &c)
MatrixXX(const ThisType &mat)
TransposedType Transposed()
T TraceAbs(const MatrixXX< N, N, T > &a)
void Rotation(T rad, MatrixXX< 2, 2, T > *a)
MatrixXX< 3, 3, float > mat3
void Transpose(BaseMatrixXX< R, C, T > *t) const
MatrixXX< C, R, T > min(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< 3, 3, float > Mat3f
T Determinant(const MatrixXX< N, N, T > &a)
T Trace(const MatrixXX< N, N, T > &a)
MatrixXX(const MatrixXX< 1, R, T > &a, const MatrixXX< 1, R, T > &b)
class A(deque< T, A >)) ARMARX_OVERLOAD_STD_HASH_FOR_ITERABLE((class T
Enables hashing of std::list.
VectorXD< D, T > sqrt(const VectorXD< D, T > &a)
MatrixXX(const SuperType &mat)
VectorXD< R, T > & operator[](unsigned int col)
double v(double t, double v0, double a0, double j)
MatrixXX< 2, 2, float > Mat2f
MatrixXX< R, C, T > TransposedType
static void AssertEqual()
MatrixXX< 2, 2, float > mat2
const MatrixXX< C, R, T > ComponentMul(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< C, R, T > & operator-=(MatrixXX< C, R, T > &m, const MatrixXX< C, R, T > &b)
MatrixXX< 3, 3, float > Matrix3f
MatrixXX< 4, 4, float > Mat4f
BaseMatrixXX< C, R, T > ThisType
double s(double t, double s0, double v0, double a0, double j)
const MatrixXX< C, R, T > SqrComponentMul(const MatrixXX< C, R, T > &a)
const VectorXD< R, T > & operator[](unsigned int col) const
const MatrixXX< C, R, T > operator+(const MatrixXX< C, R, T > &a, const MatrixXX< C, R, T > &b)
MatrixXX< 4, 4, float > mat4
const MatrixXX< C, R, T > operator*(T s, const MatrixXX< C, R, T > &a)
MatrixXX< 1, 1, T > & ComponentMul(const MatrixXX< 1, 1, T > &a)