58 template <
typename T2>
119 void set( T
const *
const ptr );
125 void set(
const Vec3T<T>& diagonal );
130 void set( T a00, T a01, T a02,
132 T a20, T a21, T a22);
138 void set(
const Quat& q );
150 const T *
ptr()
const;
299 #define DET2(a, b, c, d) ((a)*(d) - (b)*(c)) 301 #define SET_ROW(row, v1, v2, v3 ) \ 303 m_data[(row)][0] = (v1); \ 304 m_data[(row)][1] = (v2); \ 305 m_data[(row)][2] = (v3); \ 306 m_data[(row)][3] = ( 0); \ 309 #define INNER_PRODUCT(a,b,r,c) \ 310 ((a).m_data[r][0] * (b).m_data[0][c]) \ 311 +((a).m_data[r][1] * (b).m_data[1][c]) \ 312 +((a).m_data[r][2] * (b).m_data[2][c]) 314 template <
typename T>
320 template <
typename T>
323 this->
set(mat.ptr());
326 template <
typename T>
332 template <
typename T>
template <
typename T2>
351 template <
typename T>
357 template <
typename T>
364 template <
typename T>
383 template <
typename T>
400 template <
typename T>
404 m_data[0][0], m_data[0][1], m_data[0][2], 0,
405 m_data[1][0], m_data[1][1], m_data[1][2], 0,
406 m_data[2][0], m_data[2][1], m_data[2][2], 0,
412 template <
typename T>
415 return m_data[0][0] == m.m_data[0][0] &&
416 m_data[0][1] == m.m_data[0][1] &&
417 m_data[0][2] == m.m_data[0][2] &&
418 m_data[1][0] == m.m_data[1][0] &&
419 m_data[1][1] == m.m_data[1][1] &&
420 m_data[1][2] == m.m_data[1][2] &&
421 m_data[2][0] == m.m_data[2][0] &&
422 m_data[2][1] == m.m_data[2][1] &&
423 m_data[2][2] == m.m_data[2][2];
426 template <
typename T>
429 return !(*
this == m);
432 template <
typename T>
438 template <
typename T>
445 template <
typename T>
448 return !this->
isNaN();
451 template <
typename T>
454 return std::isnan(
m_data[0][0] ) || std::isnan(
m_data[0][1] ) || std::isnan(
m_data[0][2] ) ||
455 std::isnan(
m_data[1][0] ) || std::isnan(
m_data[1][1] ) || std::isnan(
m_data[1][2] ) ||
456 std::isnan(
m_data[2][0] ) || std::isnan(
m_data[2][1] ) || std::isnan(
m_data[2][2] ) ;
459 template <
typename T>
465 template <
typename T>
473 template <
typename T>
476 this->
set(rhs.ptr());
480 template <
typename T>
483 #if defined(__GNUC__) && !defined(__clang__) 484 #pragma GCC diagnostic push 485 #pragma GCC diagnostic ignored "-Wstringop-overflow" 488 memcpy(
m_data, ptr,
sizeof(T) * 12);
490 #if defined(__GNUC__) && !defined(__clang__) 491 #pragma GCC diagnostic pop 495 template <
typename T>
511 template <
typename T>
514 m_data[0][0] = diagonal[0];
518 m_data[1][1] = diagonal[1];
522 m_data[2][2] = diagonal[2];
525 template <
typename T>
531 template <
typename T>
537 template <
typename T>
543 template <
typename T>
551 template <
typename T>
559 template <
typename T>
568 template <
typename T>
576 template <
typename T>
579 m_data[0][0] = m(0,0) * r;
580 m_data[0][1] = m(0,1) * r;
581 m_data[0][2] = m(0,2) * r;
582 m_data[1][0] = m(1,0) * r;
583 m_data[1][1] = m(1,1) * r;
584 m_data[1][2] = m(1,2) * r;
585 m_data[2][0] = m(2,0) * r;
586 m_data[2][1] = m(2,1) * r;
587 m_data[2][2] = m(2,2) * r;
590 template <
typename T>
593 m_data[0][0] = a(0,0) + b(0,0);
594 m_data[0][1] = a(0,1) + b(0,1);
595 m_data[0][2] = a(0,2) + b(0,2);
596 m_data[1][0] = a(1,0) + b(1,0);
597 m_data[1][1] = a(1,1) + b(1,1);
598 m_data[1][2] = a(1,2) + b(1,2);
599 m_data[2][0] = a(2,0) + b(2,0);
600 m_data[2][1] = a(2,1) + b(2,1);
601 m_data[2][2] = a(2,2) + b(2,2);
604 template <
typename T>
607 m_data[0][0] = a(0,0) - b(0,0);
608 m_data[0][1] = a(0,1) - b(0,1);
609 m_data[0][2] = a(0,2) - b(0,2);
610 m_data[1][0] = a(1,0) - b(1,0);
611 m_data[1][1] = a(1,1) - b(1,1);
612 m_data[1][2] = a(1,2) - b(1,2);
613 m_data[2][0] = a(2,0) - b(2,0);
614 m_data[2][1] = a(2,1) - b(2,1);
615 m_data[2][2] = a(2,2) - b(2,2);
619 template <
typename T>
622 this->
mult(*
this, r);
625 template <
typename T>
628 this->
mult(*
this, T(1.0)/d);
631 template <
typename T>
637 template <
typename T>
643 template <
typename T>
651 template <
typename T>
655 t.mult( *
this, T(1.0)/r );
659 template <
typename T>
667 template <
typename T>
675 template <
typename T>
683 template <
typename T>
691 template <
typename T>
724 template <
typename T>
758 template <
typename T>
783 template <
typename T>
790 template <
typename T>
798 template <
typename T>
801 return m.preMult( v );
804 template <
typename T>
811 template <
typename T>
820 template <
typename T>
825 Vec2i coord(skipFlags[0] ? (skipFlags[1] ? 2 : 1) : 0, 0);
827 for (
int i = 0; i < 3; i++)
832 for (
int j = 0; j < 3; j++)
834 if (std::abs(mat(i, j)) > max)
837 max = std::abs(mat(i, j));
842 agxAssert(coord[0] >= 0 && coord[1] >= 0);
847 template <
typename T>
858 return this->fastInverse(determinant);
861 const int next[3] = {1, 2, 0};
865 bool done[3] = {
false,
false,
false};
866 int pivotColumns[3] = {-1, -1, -1};
868 for (
int i = 0; i < 3; i++)
871 Vec2i coord = findMaxElement(tmp, done);
872 pivotColumns[(int)coord[0]] = (
int)coord[1];
875 T *row = &tmp(coord[0], 0);
876 T *resultRow = &result(coord[0], 0);
879 T scale = T(1)/row[coord[1]];
880 for (
int j = 0; j < 3; j++)
883 resultRow[j] *= scale;
888 for (
int r = next[coord[0]]; r != coord[0]; r = next[r])
891 T *rb = &result(r, 0);
894 for (
int j = 0; j < 3; j++)
897 rb[j] -= f*resultRow[j];
901 done[coord[0]] =
true;
905 for (
int i = 0; i < 3; i++)
907 T *ra = &tmp(pivotColumns[i], 0);
908 T *rb = &result(i, 0);
909 memcpy(ra, rb,
sizeof(T) * 3);
917 template <
typename T>
918 inline std::ostream& operator<< ( std::ostream& os, const Matrix3x3T<T>& m )
920 os <<
"{" << std::endl;
921 for (
size_t row = 0; row < 3; ++row ) {
923 for (
size_t col = 0; col < 3; ++col )
924 os << m( row, col ) <<
" ";
927 os <<
"}" << std::endl;
931 template <
typename T>
bool operator==(const Matrix3x3T< T > &m) const
Equality test (no threshold, must be exact same bits).
void operator-=(const Matrix3x3T< T > &m)
Set the value of the matrix to the result of the subtraction between this matrix and the matrix m...
void makeIdentity()
Set all values.
Matrix3x3T< T > operator*(const T &r) const
Matrix3x3T< T > operator+(const Matrix3x3T< T > &m) const
T determinant() const
Calculate the determinant.
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Matrix3x3T< T > operator/(const T &r) const
AGXCORE_EXPORT const Real RealEpsilon
Matrix3x3T< T > & operator=(const Matrix3x3T< T > &rhs)
T * ptr()
Access internal buffer.
Vec3T< T > postMult(const Vec3T< T > &v) const
bool isValid() const
State queries.
T & operator()(size_t row, size_t col)
Element accessors.
void sub(const Matrix3x3T< T > &a, const Matrix3x3T< T > &b)
Set the value of this matrix to the result of the subtraction between the matrix m and the matrix b...
#define AGX_TYPE_BINDING(_Type, _Name)
void operator/=(const T &d)
Set the value of the matrix to the quotient of the division between this matrix and the divisor r...
Matrix3x3T()
Default constructor, provides an identity matrix.
Matrix3x3T< T > operator-(const Matrix3x3T< T > &m) const
void mult(const Matrix3x3T< T > &m, const T &r)
Set the value of this matrix to the result of the product between the matrix m and the scalar r...
Matrix3x3T< Real32 > Matrix3x3f
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
T dotColumn(const Vec3T< T > &vec, size_t col) const
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Vec3T< T > getDiagonal() const
Get the diagonal elements.
Matrix class for rigid transformations (translation, rotation).
Specialized type of matrices for holding symmetric positive definite matrices.
Matrix3x3T< Real > Matrix3x3
void add(const Matrix3x3T< T > &a, const Matrix3x3T< T > &b)
Set the value of this matrix to the result of the sum between the matrix m and the matrix b...
bool operator!=(const Matrix3x3T< T > &m) const
void operator+=(const Matrix3x3T< T > &m)
Set the value of the matrix to the result of the sum between this matrix and the matrix m...
Matrix3x3T< T > inverse() const
Calculate the inverse.
Vec3T< T > preMult(const Vec3T< T > &v) const
A class holding 3 dimensional vectors and providing basic arithmetic.
bool isDiagonal() const
Test if matrix is diagonal.
Matrix3x3T< Real64 > Matrix3x3d
Matrix3x3T< T > transpose() const
Calculate the transpose.
static Matrix3x3T< T > crossMatrix(const Vec3T< T > &v)
Create a cross product matrix.
void operator*=(const T &r)
Set the value of the matrix to the result of the product between this matrix and the scalar r...
#define INNER_PRODUCT(a, b, r, c)
void set(T const *const ptr)
#define SET_ROW(row, v1, v2, v3)