16 #ifndef AGX_AFFINEMATRIX4X4_H 17 #define AGX_AFFINEMATRIX4X4_H 20 # pragma warning(push) 21 # pragma warning(disable: 4714) // Disable warnings about not able to force inline 24 #include <agx/config/AGX_USE_SSE.h> 33 #define AGX_AFFINEMATRIX4X4_SET_ROW(row, v1, v2, v3 ) \ 34 this->m_data[(row)][0] = (v1); \ 35 this->m_data[(row)][1] = (v2); \ 36 this->m_data[(row)][2] = (v3); 38 #define AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(a,b,r,c) \ 39 ((a).m_data[r][0] * (b).m_data[0][c]) \ 40 +((a).m_data[r][1] * (b).m_data[1][c]) \ 41 +((a).m_data[r][2] * (b).m_data[2][c]) 65 #if defined(SWIG) && !defined(SWIGJAVA) 69 template <
typename T2>
89 T a10, T a11, T a12, T a13,
90 T a20, T a21, T a22, T a23,
91 T a30, T a31, T a32, T a33 );
151 T a10, T a11, T a12, T a13,
152 T a20, T a21, T a22, T a23,
153 T a30, T a31, T a32, T a33);
380 Real at(
size_t i,
size_t j)
const;
383 void set(
Real val,
size_t i,
size_t j);
411 template <
typename T>
417 template <
typename T>
template <
typename T2>
422 template <
typename T>
424 T a10, T a11, T a12, T a13,
425 T a20, T a21, T a22, T a23,
426 T a30, T a31, T a32, T a33 ) :
Matrix4x4T<T>(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33)
428 agxAssert(this->isRigidTransformation());
431 template <
typename T>
438 template <
typename T>
443 template <
typename T>
448 template <
typename T>
460 template <
typename T>
468 template <
typename T>
471 T x = this->m_data[3][0];
472 T y = this->m_data[3][1];
473 T z = this->m_data[3][2];
477 invTranslate[0] = -( x * this->m_data[0][0] + y* this->m_data[0][1] + z * this->m_data[0][2]);
478 invTranslate[1] = -( x * this->m_data[1][0] + y* this->m_data[1][1] + z * this->m_data[1][2]);
479 invTranslate[2] = -( x * this->m_data[2][0] + y* this->m_data[2][1] + z * this->m_data[2][2]);
484 template <
typename T>
487 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
488 return (bitCompare == 0);
491 template <
typename T>
494 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
495 return (bitCompare != 0);
502 template <
typename T>
506 #if defined(__GNUC__) && !defined(__clang__) 507 #pragma GCC diagnostic push 508 #pragma GCC diagnostic ignored "-Wstringop-overflow" 511 memcpy(this->m_data, ptr,
sizeof(T)*16);
513 #if defined(__GNUC__) && !defined(__clang__) 514 #pragma GCC diagnostic pop 517 agxAssert(this->isRigidTransformation());
522 template <
typename T>
524 T a10, T a11, T a12, T a13,
525 T a20, T a21, T a22, T a23,
526 T a30, T a31, T a32, T a33 )
529 Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
533 template <
typename T>
537 this->setTranslate(0.0, 0.0, 0.0);
543 template <
typename T>
547 this->setTranslate(0.0, 0.0, 0.0);
552 template <
typename T>
560 template <
typename T>
563 (*this)(0,0) = (T)m3(0,0);
564 (*this)(0,1) = (T)m3(0,1);
565 (*this)(0,2) = (T)m3(0,2);
567 (*this)(1,0) = (T)m3(1,0);
568 (*this)(1,1) = (T)m3(1,1);
569 (*this)(1,2) = (T)m3(1,2);
571 (*this)(2,0) = (T)m3(2,0);
572 (*this)(2,1) = (T)m3(2,1);
573 (*this)(2,2) = (T)m3(2,2);
578 template <
typename T>
583 this->setRotate(quat);
587 template <
typename T>
592 this->setRotate(quat);
596 template <
typename T>
601 this->setRotate(quat);
605 template <
typename T>
614 this->setRotate(quat);
618 template <
typename T>
621 this->m_data[3][0] = t[0];
622 this->m_data[3][1] = t[1];
623 this->m_data[3][2] = t[2];
628 template <
typename T>
631 this->m_data[3][0] = tx;
632 this->m_data[3][1] = ty;
633 this->m_data[3][2] = tz;
639 template <
typename T>
642 this->
set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
651 template <
typename T>
655 0, -vec.
z(), vec.
y(), 0,
656 vec.
z(), 0, -vec.
x(), 0,
657 -vec.
y(), vec.
x(), 0, 0,
662 template <
typename T>
670 template <
typename T>
678 template <
typename T>
686 template <
typename T>
694 template <
typename T>
702 template <
typename T>
708 m.
setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
716 template <
typename T>
719 agx::prefetch<agx::L1>( lhs.
m_data );
720 agx::prefetch<agx::L1>( rhs.
m_data );
751 template <
typename T>
757 for(
size_t col=0; col<3; ++col) {
762 this->m_data[0][col] = t[0];
763 this->m_data[1][col] = t[1];
764 this->m_data[2][col] = t[2];
765 this->m_data[3][col] = t[3] + this->m_data[3][col];
769 template <
typename T>
775 for(
size_t row=0; row<3; ++row)
790 template <
typename T>
793 for (
unsigned i = 0; i < 3; ++i)
795 this->m_data[3][0] += v[i]*this->m_data[i][0];
796 this->m_data[3][1] += v[i]*this->m_data[i][1];
797 this->m_data[3][2] += v[i]*this->m_data[i][2];
798 this->m_data[3][3] += v[i]*this->m_data[i][3];
803 template <
typename T>
806 for (
unsigned i = 0; i < 3; ++i)
808 this->m_data[0][i] += v[i]*this->m_data[0][3];
809 this->m_data[1][i] += v[i]*this->m_data[1][3];
810 this->m_data[2][i] += v[i]*this->m_data[2][3];
811 this->m_data[3][i] += v[i]*this->m_data[3][3];
818 template <
typename T>
822 this->
set( rhs.
ptr() );
828 template <
typename T>
836 template <
typename T>
845 template <
typename T>
848 if (
this == &other )
853 else postMult( other );
857 template <
typename T>
863 template <
typename T>
869 template <
typename T>
874 template <
typename T>
883 template <
typename T>
889 this->m_data[0][0] = rhs.
m_data[0][0];
890 this->m_data[1][1] = rhs.
m_data[1][1];
891 this->m_data[2][2] = rhs.
m_data[2][2];
894 this->m_data[0][1] = rhs.
m_data[1][0];
895 this->m_data[1][0] = rhs.
m_data[0][1];
896 this->m_data[0][2] = rhs.
m_data[2][0];
897 this->m_data[2][0] = rhs.
m_data[0][2];
898 this->m_data[1][2] = rhs.
m_data[2][1];
899 this->m_data[2][1] = rhs.
m_data[1][2];
906 this->m_data[3][0] = -( x * this->m_data[0][0] + y* this->m_data[1][0] + z * this->m_data[2][0]);
907 this->m_data[3][1] = -( x * this->m_data[0][1] + y* this->m_data[1][1] + z * this->m_data[2][1]);
908 this->m_data[3][2] = -( x * this->m_data[0][2] + y* this->m_data[1][2] + z * this->m_data[2][2]);
913 template <
typename T>
940 multSSE32Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
950 multSSE64Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
971 template <
typename T>
974 return Real((*
this)(i,j));
977 template <
typename T>
980 (*this)(i,j) = T(val);
984 template <
typename T>
987 return point * (*this);
990 template <
typename T>
993 return this->transform3x3(vector);
1006 # pragma warning(pop) Real mult(const Jacobian6DOFElementT< T > &G1, const Jacobian6DOFElementT< T > &G2)
AffineMatrix4x4T< Real > AffineMatrix4x4
Real at(size_t i, size_t j) const
static AffineMatrix4x4T< T > translate(const Vec3T< T > &dv)
Return a matrix which translates according to dv.
void postMult(const AffineMatrix4x4T< T > &)
A class holding 4 dimensional vectors and providing basic arithmetic.
static AffineMatrix4x4T< T > rotate(const Vec3T< T > &from, const Vec3T< T > &to)
Return a matrix which rotate a vector from from to to.
bool operator==(T val, InvalidIndexStruct)
#define AGX_TYPE_BINDING(_Type, _Name)
Vec4T< T > operator*(const Vec4T< T > &v, const AffineMatrix4x4T< T > &m)
Matrix class for affine transformations.
AffineMatrix4x4d inverse< AffineMatrix4x4d >(const AffineMatrix4x4d &value)
const Real AGX_EQUIVALENT_EPSILON
AffineMatrix4x4T()
Creates a new matrix, initialized to be an identity matrix.
void multSSE(const AffineMatrix4x4T< T > &lhs, const AffineMatrix4x4T< T > &rhs)
agx::Vec3T< T > transformVector(const agx::Vec3T< T > &vector) const
Transforms a (mathematical) vector, using only rotation.
T inverse(const T &value)
AffineMatrix4x4T< Real32 > AffineMatrix4x4f
bool equivalent(const agx::AffineMatrix4x4T< T > &a, const agx::AffineMatrix4x4T< T > &b, T epsilon=T(AGX_EQUIVALENT_EPSILON))
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
void mult(const AffineMatrix4x4T< T > &, const AffineMatrix4x4T< T > &)
AffineMatrix4x4T< T > operator*(const AffineMatrix4x4T< T > &m) const
AffineMatrix4x4T< Real64 > AffineMatrix4x4d
bool operator!=(const AffineMatrix4x4T< T > &m) const
AffineMatrix4x4T< T > & setIdentity()
Set the value of the matrix to the identity matrix.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
#define AGX_AFFINEMATRIX4X4_SET_ROW(row, v1, v2, v3)
The object holding quaternions and providing operations on these.
Matrix class for rigid transformations (translation, rotation).
static AffineMatrix4x4T< T > crossMatrix(const Vec3T< T > &vec)
Generates a new matrix of a specific type.
void preMult(const AffineMatrix4x4T< T > &)
AffineMatrix4x4f inverse< AffineMatrix4x4f >(const AffineMatrix4x4f &value)
agx::Vec3T< T > transformPoint(const agx::Vec3T< T > &point) const
Transforms a (mathematical) point, using both rotation and translation.
void operator*=(const AffineMatrix4x4T< T > &other)
void mult(const Matrix4x4T< T > &, const Matrix4x4T< T > &)
bool invert(const AffineMatrix4x4T< T > &rhs)
#define AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(a, b, r, c)
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)
A class holding 3 dimensional vectors and providing basic arithmetic.
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
AffineMatrix4x4T< T > & operator=(const AffineMatrix4x4T< T > &rhs)
Vec3T< T > getInvTranslate() const
AffineMatrix4x4T< T > & setRotate(const QuatT< T > &q)
Set the rotational part of the matrix using the specified quaternion leaving the translational part u...
bool operator!=(T val, InvalidIndexStruct)
AffineMatrix4x4T< T > & postMultTranslate(const Vec3T< T > &v)
AffineMatrix4x4T< T > & preMultTranslate(const Vec3T< T > &v)
~AffineMatrix4x4T()=default
Destructor.
bool operator==(const AffineMatrix4x4T< T > &m) const
void setRotate(T angle, T x, T y, T z)
Set the rotation of the Quaternion as a rotation angle radians around the vector (x, y, z)
AffineMatrix4x4T< T > & setTranslate(const Vec3T< T > &t)
Set the translational part of the matrix using the vector t.
Specialized types of matrices for holding orthogonal transformation matrices.