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;
306 #define DET2(a, b, c, d) ((a)*(d) - (b)*(c)) 308 #define SET_ROW(row, v1, v2, v3 ) \ 310 m_data[(row)][0] = (v1); \ 311 m_data[(row)][1] = (v2); \ 312 m_data[(row)][2] = (v3); \ 313 m_data[(row)][3] = ( 0); \ 316 #define INNER_PRODUCT(a,b,r,c) \ 317 ((a).m_data[r][0] * (b).m_data[0][c]) \ 318 +((a).m_data[r][1] * (b).m_data[1][c]) \ 319 +((a).m_data[r][2] * (b).m_data[2][c]) 321 template <
typename T>
327 template <
typename T>
330 this->
set(mat.ptr());
333 template <
typename T>
339 template <
typename T>
template <
typename T2>
358 template <
typename T>
364 template <
typename T>
371 template <
typename T>
390 template <
typename T>
407 template <
typename T>
411 m_data[0][0], m_data[0][1], m_data[0][2], 0,
412 m_data[1][0], m_data[1][1], m_data[1][2], 0,
413 m_data[2][0], m_data[2][1], m_data[2][2], 0,
419 template <
typename T>
422 return m_data[0][0] == m.m_data[0][0] &&
423 m_data[0][1] == m.m_data[0][1] &&
424 m_data[0][2] == m.m_data[0][2] &&
425 m_data[1][0] == m.m_data[1][0] &&
426 m_data[1][1] == m.m_data[1][1] &&
427 m_data[1][2] == m.m_data[1][2] &&
428 m_data[2][0] == m.m_data[2][0] &&
429 m_data[2][1] == m.m_data[2][1] &&
430 m_data[2][2] == m.m_data[2][2];
433 template <
typename T>
436 return !(*
this == m);
439 template <
typename T>
445 template <
typename T>
452 template <
typename T>
455 return !this->
isNaN();
458 template <
typename T>
461 return std::isnan(
m_data[0][0] ) || std::isnan(
m_data[0][1] ) || std::isnan(
m_data[0][2] ) ||
462 std::isnan(
m_data[1][0] ) || std::isnan(
m_data[1][1] ) || std::isnan(
m_data[1][2] ) ||
463 std::isnan(
m_data[2][0] ) || std::isnan(
m_data[2][1] ) || std::isnan(
m_data[2][2] ) ;
466 template <
typename T>
472 template <
typename T>
480 template <
typename T>
483 this->
set(rhs.ptr());
487 template <
typename T>
490 memcpy(
m_data, ptr,
sizeof(T) * 12);
493 template <
typename T>
509 template <
typename T>
512 m_data[0][0] = diagonal[0];
516 m_data[1][1] = diagonal[1];
520 m_data[2][2] = diagonal[2];
523 template <
typename T>
529 template <
typename T>
535 template <
typename T>
541 template <
typename T>
549 template <
typename T>
557 template <
typename T>
566 template <
typename T>
574 template <
typename T>
577 m_data[0][0] = m(0,0) * r;
578 m_data[0][1] = m(0,1) * r;
579 m_data[0][2] = m(0,2) * r;
580 m_data[1][0] = m(1,0) * r;
581 m_data[1][1] = m(1,1) * r;
582 m_data[1][2] = m(1,2) * r;
583 m_data[2][0] = m(2,0) * r;
584 m_data[2][1] = m(2,1) * r;
585 m_data[2][2] = m(2,2) * r;
588 template <
typename T>
591 m_data[0][0] = a(0,0) + b(0,0);
592 m_data[0][1] = a(0,1) + b(0,1);
593 m_data[0][2] = a(0,2) + b(0,2);
594 m_data[1][0] = a(1,0) + b(1,0);
595 m_data[1][1] = a(1,1) + b(1,1);
596 m_data[1][2] = a(1,2) + b(1,2);
597 m_data[2][0] = a(2,0) + b(2,0);
598 m_data[2][1] = a(2,1) + b(2,1);
599 m_data[2][2] = a(2,2) + b(2,2);
602 template <
typename T>
605 m_data[0][0] = a(0,0) - b(0,0);
606 m_data[0][1] = a(0,1) - b(0,1);
607 m_data[0][2] = a(0,2) - b(0,2);
608 m_data[1][0] = a(1,0) - b(1,0);
609 m_data[1][1] = a(1,1) - b(1,1);
610 m_data[1][2] = a(1,2) - b(1,2);
611 m_data[2][0] = a(2,0) - b(2,0);
612 m_data[2][1] = a(2,1) - b(2,1);
613 m_data[2][2] = a(2,2) - b(2,2);
617 template <
typename T>
620 this->
mult(*
this, r);
623 template <
typename T>
626 this->
mult(*
this, T(1.0)/d);
629 template <
typename T>
635 template <
typename T>
641 template <
typename T>
649 template <
typename T>
653 t.mult( *
this, T(1.0)/r );
657 template <
typename T>
665 template <
typename T>
673 template <
typename T>
681 template <
typename T>
689 template <
typename T>
722 template <
typename T>
756 template <
typename T>
781 template <
typename T>
788 template <
typename T>
796 template <
typename T>
799 return m.preMult( v );
802 template <
typename T>
809 template <
typename T>
818 template <
typename T>
823 Vec2i coord(skipFlags[0] ? (skipFlags[1] ? 2 : 1) : 0, 0);
825 for (
int i = 0; i < 3; i++)
830 for (
int j = 0; j < 3; j++)
832 if (std::abs(mat(i, j)) > max)
835 max = std::abs(mat(i, j));
840 agxAssert(coord[0] >= 0 && coord[1] >= 0);
845 template <
typename T>
856 return this->fastInverse(determinant);
859 const int next[3] = {1, 2, 0};
863 bool done[3] = {
false,
false,
false};
864 int pivotColumns[3] = {-1, -1, -1};
866 for (
int i = 0; i < 3; i++)
869 Vec2i coord = findMaxElement(tmp, done);
870 pivotColumns[(int)coord[0]] = (
int)coord[1];
873 T *row = &tmp(coord[0], 0);
874 T *resultRow = &result(coord[0], 0);
877 T scale = T(1)/row[coord[1]];
878 for (
int j = 0; j < 3; j++)
881 resultRow[j] *= scale;
886 for (
int r = next[coord[0]]; r != coord[0]; r = next[r])
889 T *rb = &result(r, 0);
892 for (
int j = 0; j < 3; j++)
895 rb[j] -= f*resultRow[j];
899 done[coord[0]] =
true;
903 for (
int i = 0; i < 3; i++)
905 T *ra = &tmp(pivotColumns[i], 0);
906 T *rb = &result(i, 0);
907 memcpy(ra, rb,
sizeof(T) * 3);
915 template <
typename T>
916 inline std::ostream& operator<< ( std::ostream& os, const Matrix3x3T<T>& m )
918 os <<
"{" << std::endl;
919 for (
size_t row = 0; row < 3; ++row ) {
921 for (
size_t col = 0; col < 3; ++col )
922 os << m( row, col ) <<
" ";
925 os <<
"}" << std::endl;
929 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
Namespace agx 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
Real at(size_t i, size_t j)
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)