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 template <
typename T2>
83 T a10, T a11, T a12, T a13,
84 T a20, T a21, T a22, T a23,
85 T a30, T a31, T a32, T a33 );
145 T a10, T a11, T a12, T a13,
146 T a20, T a21, T a22, T a23,
147 T a30, T a31, T a32, T a33);
374 Real at(
size_t i,
size_t j)
const;
377 void set(
Real val,
size_t i,
size_t j);
405 template <
typename T>
411 template <
typename T>
template <
typename T2>
416 template <
typename T>
418 T a10, T a11, T a12, T a13,
419 T a20, T a21, T a22, T a23,
420 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)
422 agxAssert(this->isRigidTransformation());
425 template <
typename T>
432 template <
typename T>
437 template <
typename T>
442 template <
typename T>
454 template <
typename T>
462 template <
typename T>
465 T x = this->m_data[3][0];
466 T y = this->m_data[3][1];
467 T z = this->m_data[3][2];
471 invTranslate[0] = -( x * this->m_data[0][0] + y* this->m_data[0][1] + z * this->m_data[0][2]);
472 invTranslate[1] = -( x * this->m_data[1][0] + y* this->m_data[1][1] + z * this->m_data[1][2]);
473 invTranslate[2] = -( x * this->m_data[2][0] + y* this->m_data[2][1] + z * this->m_data[2][2]);
478 template <
typename T>
481 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
482 return (bitCompare == 0);
485 template <
typename T>
488 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
489 return (bitCompare != 0);
496 template <
typename T>
499 memcpy(this->m_data, ptr,
sizeof(T)*16);
500 agxAssert(this->isRigidTransformation());
505 template <
typename T>
507 T a10, T a11, T a12, T a13,
508 T a20, T a21, T a22, T a23,
509 T a30, T a31, T a32, T a33 )
512 Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
516 template <
typename T>
520 this->setTranslate(0.0, 0.0, 0.0);
526 template <
typename T>
530 this->setTranslate(0.0, 0.0, 0.0);
535 template <
typename T>
543 template <
typename T>
546 (*this)(0,0) = (T)m3(0,0);
547 (*this)(0,1) = (T)m3(0,1);
548 (*this)(0,2) = (T)m3(0,2);
550 (*this)(1,0) = (T)m3(1,0);
551 (*this)(1,1) = (T)m3(1,1);
552 (*this)(1,2) = (T)m3(1,2);
554 (*this)(2,0) = (T)m3(2,0);
555 (*this)(2,1) = (T)m3(2,1);
556 (*this)(2,2) = (T)m3(2,2);
561 template <
typename T>
566 this->setRotate(quat);
570 template <
typename T>
575 this->setRotate(quat);
579 template <
typename T>
584 this->setRotate(quat);
588 template <
typename T>
597 this->setRotate(quat);
601 template <
typename T>
604 this->m_data[3][0] = t[0];
605 this->m_data[3][1] = t[1];
606 this->m_data[3][2] = t[2];
611 template <
typename T>
614 this->m_data[3][0] = tx;
615 this->m_data[3][1] = ty;
616 this->m_data[3][2] = tz;
622 template <
typename T>
625 this->
set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
634 template <
typename T>
638 0, -vec.
z(), vec.
y(), 0,
639 vec.
z(), 0, -vec.
x(), 0,
640 -vec.
y(), vec.
x(), 0, 0,
645 template <
typename T>
653 template <
typename T>
661 template <
typename T>
669 template <
typename T>
677 template <
typename T>
685 template <
typename T>
691 m.
setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
699 template <
typename T>
702 agx::prefetch<agx::L1>( lhs.
m_data );
703 agx::prefetch<agx::L1>( rhs.
m_data );
734 template <
typename T>
740 for(
size_t col=0; col<3; ++col) {
745 this->m_data[0][col] = t[0];
746 this->m_data[1][col] = t[1];
747 this->m_data[2][col] = t[2];
748 this->m_data[3][col] = t[3] + this->m_data[3][col];
752 template <
typename T>
758 for(
size_t row=0; row<3; ++row)
773 template <
typename T>
776 for (
unsigned i = 0; i < 3; ++i)
778 this->m_data[3][0] += v[i]*this->m_data[i][0];
779 this->m_data[3][1] += v[i]*this->m_data[i][1];
780 this->m_data[3][2] += v[i]*this->m_data[i][2];
781 this->m_data[3][3] += v[i]*this->m_data[i][3];
786 template <
typename T>
789 for (
unsigned i = 0; i < 3; ++i)
791 this->m_data[0][i] += v[i]*this->m_data[0][3];
792 this->m_data[1][i] += v[i]*this->m_data[1][3];
793 this->m_data[2][i] += v[i]*this->m_data[2][3];
794 this->m_data[3][i] += v[i]*this->m_data[3][3];
801 template <
typename T>
805 this->
set( rhs.
ptr() );
811 template <
typename T>
819 template <
typename T>
828 template <
typename T>
831 if (
this == &other )
836 else postMult( other );
840 template <
typename T>
846 template <
typename T>
852 template <
typename T>
857 template <
typename T>
866 template <
typename T>
872 this->m_data[0][0] = rhs.
m_data[0][0];
873 this->m_data[1][1] = rhs.
m_data[1][1];
874 this->m_data[2][2] = rhs.
m_data[2][2];
877 this->m_data[0][1] = rhs.
m_data[1][0];
878 this->m_data[1][0] = rhs.
m_data[0][1];
879 this->m_data[0][2] = rhs.
m_data[2][0];
880 this->m_data[2][0] = rhs.
m_data[0][2];
881 this->m_data[1][2] = rhs.
m_data[2][1];
882 this->m_data[2][1] = rhs.
m_data[1][2];
889 this->m_data[3][0] = -( x * this->m_data[0][0] + y* this->m_data[1][0] + z * this->m_data[2][0]);
890 this->m_data[3][1] = -( x * this->m_data[0][1] + y* this->m_data[1][1] + z * this->m_data[2][1]);
891 this->m_data[3][2] = -( x * this->m_data[0][2] + y* this->m_data[1][2] + z * this->m_data[2][2]);
896 template <
typename T>
923 multSSE32Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
933 multSSE64Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
954 template <
typename T>
957 return Real((*
this)(i,j));
960 template <
typename T>
963 (*this)(i,j) = T(val);
967 template <
typename T>
970 return point * (*this);
973 template <
typename T>
976 return this->transform3x3(vector);
989 # 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.
Namespace agx 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.