20# pragma warning(disable: 4714)
32#define AGX_AFFINEMATRIX4X4_SET_ROW(row, v1, v2, v3 ) \
33 this->m_data[(row)][0] = (v1); \
34 this->m_data[(row)][1] = (v2); \
35 this->m_data[(row)][2] = (v3);
37#define AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(a,b,r,c) \
38 ((a).m_data[r][0] * (b).m_data[0][c]) \
39 +((a).m_data[r][1] * (b).m_data[1][c]) \
40 +((a).m_data[r][2] * (b).m_data[2][c])
69 template <typename T2, std::enable_if_t<std::is_same<T, T2>::value == 0,
bool> =
false >
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);
389 static_assert(std::is_trivially_copyable<agx::AffineMatrix4x4T<double>>::value,
"Fix class");
390 static_assert(std::is_trivially_copy_constructible<agx::AffineMatrix4x4T<double>>::value,
"Fix class");
414 template <
typename T> template <typename T2, std::enable_if_t<std::is_same<T, T2>::value == 0,
bool> >
420 template <
typename T>
422 T a10, T a11, T a12, T a13,
423 T a20, T a21, T a22, T a23,
424 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)
429 template <
typename T>
436 template <
typename T>
441 template <
typename T>
446 template <
typename T>
458 template <
typename T>
466 template <
typename T>
469 T x = this->m_data[3][0];
470 T y = this->m_data[3][1];
471 T z = this->m_data[3][2];
475 invTranslate[0] = -( x * this->m_data[0][0] + y* this->m_data[0][1] + z * this->m_data[0][2]);
476 invTranslate[1] = -( x * this->m_data[1][0] + y* this->m_data[1][1] + z * this->m_data[1][2]);
477 invTranslate[2] = -( x * this->m_data[2][0] + y* this->m_data[2][1] + z * this->m_data[2][2]);
482 template <
typename T>
485 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
486 return (bitCompare == 0);
489 template <
typename T>
492 const int bitCompare = memcmp(this->m_data, m.
m_data,
sizeof(this->m_data));
493 return (bitCompare != 0);
500 template <
typename T>
504 #if defined(__GNUC__) && !defined(__clang__)
505 #pragma GCC diagnostic push
506 #pragma GCC diagnostic ignored "-Wstringop-overflow"
509 memcpy(this->m_data, ptr,
sizeof(T)*16);
511 #if defined(__GNUC__) && !defined(__clang__)
512 #pragma GCC diagnostic pop
515 agxAssert(this->isRigidTransformation());
520 template <
typename T>
522 T a10, T a11, T a12, T a13,
523 T a20, T a21, T a22, T a23,
524 T a30, T a31, T a32, T a33 )
527 Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
531 template <
typename T>
535 this->setTranslate(0.0, 0.0, 0.0);
541 template <
typename T>
545 this->setTranslate(0.0, 0.0, 0.0);
550 template <
typename T>
558 template <
typename T>
561 (*this)(0,0) = (T)m3(0,0);
562 (*this)(0,1) = (T)m3(0,1);
563 (*this)(0,2) = (T)m3(0,2);
565 (*this)(1,0) = (T)m3(1,0);
566 (*this)(1,1) = (T)m3(1,1);
567 (*this)(1,2) = (T)m3(1,2);
569 (*this)(2,0) = (T)m3(2,0);
570 (*this)(2,1) = (T)m3(2,1);
571 (*this)(2,2) = (T)m3(2,2);
576 template <
typename T>
581 this->setRotate(quat);
585 template <
typename T>
590 this->setRotate(quat);
594 template <
typename T>
599 this->setRotate(quat);
603 template <
typename T>
612 this->setRotate(quat);
616 template <
typename T>
619 this->m_data[3][0] = t[0];
620 this->m_data[3][1] = t[1];
621 this->m_data[3][2] = t[2];
626 template <
typename T>
629 this->m_data[3][0] = tx;
630 this->m_data[3][1] = ty;
631 this->m_data[3][2] = tz;
637 template <
typename T>
640 this->set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
649 template <
typename T>
653 0, -vec.
z(), vec.
y(), 0,
654 vec.
z(), 0, -vec.
x(), 0,
655 -vec.
y(), vec.
x(), 0, 0,
660 template <
typename T>
668 template <
typename T>
676 template <
typename T>
684 template <
typename T>
692 template <
typename T>
700 template <
typename T>
706 m.
setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
714 template <
typename T>
717 agx::prefetch<agx::L1>( lhs.
m_data );
718 agx::prefetch<agx::L1>( rhs.
m_data );
749 template <
typename T>
755 for(
size_t col=0; col<3; ++col) {
760 this->m_data[0][col] = t[0];
761 this->m_data[1][col] = t[1];
762 this->m_data[2][col] = t[2];
763 this->m_data[3][col] = t[3] + this->m_data[3][col];
767 template <
typename T>
773 for(
size_t row=0; row<3; ++row)
788 template <
typename T>
791 for (
unsigned i = 0; i < 3; ++i)
793 this->m_data[3][0] += v[i]*this->m_data[i][0];
794 this->m_data[3][1] += v[i]*this->m_data[i][1];
795 this->m_data[3][2] += v[i]*this->m_data[i][2];
796 this->m_data[3][3] += v[i]*this->m_data[i][3];
801 template <
typename T>
804 for (
unsigned i = 0; i < 3; ++i)
806 this->m_data[0][i] += v[i]*this->m_data[0][3];
807 this->m_data[1][i] += v[i]*this->m_data[1][3];
808 this->m_data[2][i] += v[i]*this->m_data[2][3];
809 this->m_data[3][i] += v[i]*this->m_data[3][3];
814 template <
typename T>
822 template <
typename T>
831 template <
typename T>
834 if (
this == &other )
839 else postMult( other );
843 template <
typename T>
849 template <
typename T>
855 template <
typename T>
860 template <
typename T>
869 template <
typename T>
875 this->m_data[0][0] = rhs.
m_data[0][0];
876 this->m_data[1][1] = rhs.
m_data[1][1];
877 this->m_data[2][2] = rhs.
m_data[2][2];
880 this->m_data[0][1] = rhs.
m_data[1][0];
881 this->m_data[1][0] = rhs.
m_data[0][1];
882 this->m_data[0][2] = rhs.
m_data[2][0];
883 this->m_data[2][0] = rhs.
m_data[0][2];
884 this->m_data[1][2] = rhs.
m_data[2][1];
885 this->m_data[2][1] = rhs.
m_data[1][2];
892 this->m_data[3][0] = -( x * this->m_data[0][0] + y* this->m_data[1][0] + z * this->m_data[2][0]);
893 this->m_data[3][1] = -( x * this->m_data[0][1] + y* this->m_data[1][1] + z * this->m_data[2][1]);
894 this->m_data[3][2] = -( x * this->m_data[0][2] + y* this->m_data[1][2] + z * this->m_data[2][2]);
899 template <
typename T>
926 multSSE32Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
936 multSSE64Implementation(this->ptr(), lhs.
ptr(), rhs.
ptr());
957 template <
typename T>
960 return Real((*
this)(i,j));
963 template <
typename T>
966 (*this)(i,j) = T(val);
970 template <
typename T>
973 return point * (*this);
976 template <
typename T>
979 return this->transform3x3(vector);
#define AGX_AFFINEMATRIX4X4_SET_ROW(row, v1, v2, v3)
#define AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(a, b, r, c)
#define AGX_TYPE_BINDING(_Type, _Name)
Matrix class for rigid transformations (translation, rotation).
~AffineMatrix4x4T()=default
Destructor.
AffineMatrix4x4T< T > & setRotate(T angle, const Vec3T< T > &axis)
Set the rotational part of a matrix which rotate angle radians around vector axis.
static AffineMatrix4x4T< T > rotate(T angle, T x, T y, T z)
Return a matrix which rotate angle radians around vector [x,y,z].
AffineMatrix4x4T< T > & setRotate(const OrthoMatrix3x3 &m3)
Set the rotational part of the matrix using the specified rotation matrix leaving the translational p...
AffineMatrix4x4T< T > & setRotate(T angle, T x, T y, T z)
Set the rotational part of a matrix which rotate angle radians around vector x y z.
Real at(size_t i, size_t j) const
AffineMatrix4x4T< T > & set(const EulerAngles &euler)
Set the rotational part of the matrix using the specified euler angles and the translational part to ...
static AffineMatrix4x4T< T > rotate(T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3)
Return a matrix which rotate angle1 radians around vector axis1 and angle2 radians around vector axis...
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==(const AffineMatrix4x4T< T > &m) const
static AffineMatrix4x4T< T > rotate(const Vec3T< T > &from, const Vec3T< T > &to)
Return a matrix which rotate a vector from from to to.
static AffineMatrix4x4T< T > translate(const Vec3T< T > &dv)
Return a matrix which translates according to dv.
AffineMatrix4x4T< T > operator*(const AffineMatrix4x4T< T > &m) const
void postMult(const AffineMatrix4x4T< T > &)
AffineMatrix4x4T< T > & setRotate(const EulerAngles &euler)
Set the rotational part of the matrix using the specified euler angles leaving the translational part...
static AffineMatrix4x4T< T > crossMatrix(const Vec3T< T > &vec)
Generates a new matrix of a specific type.
AffineMatrix4x4T(const AffineMatrix4x4T< T2 > &mat)
Copy constructor.
static AffineMatrix4x4T< T > rotate(const EulerAngles &euler)
AffineMatrix4x4T(const QuatT< T > &rotation, const Vec3T< T > &translation=Vec3T< T >())
Create a matrix from a quaternion.
bool invert(const AffineMatrix4x4T< T > &rhs)
AffineMatrix4x4T< T > & setRotate(T angle1, const Vec3T< T > &axis1, T angle2, const Vec3T< T > &axis2, T angle3, const Vec3T< T > &axis3)
Set the rotational part of a matrix which rotate angle1 radians around vector axis1 and angle2 radian...
void preMult(const AffineMatrix4x4T< T > &)
AffineMatrix4x4T()=default
Creates a new matrix, initialized to be an identity matrix.
AffineMatrix4x4T< T > & set(T const *const ptr)
Set the entire matrix using values from the array with 16 elements using the following order:
Vec3T< T > getInvTranslate() const
agx::Vec3T< T > transformVector(const agx::Vec3T< T > &vector) const
Transforms a (mathematical) vector, using only rotation.
AffineMatrix4x4T(T const *const ptr)
Create a matrix from a vector of 16 reals.
void multSSE(const AffineMatrix4x4T< T > &lhs, const AffineMatrix4x4T< T > &rhs)
AffineMatrix4x4T< T > & setTranslate(const Vec3T< T > &t)
Set the translational part of the matrix using the vector t.
AffineMatrix4x4T(const OrthoMatrix3x3 &rotation, const Vec3T< T > &translation=Vec3T< T >())
Create a matrix from a 3x3 rotation matrix.
AffineMatrix4x4T< T > & set(const OrthoMatrix3x3 &m3)
Set the rotational part of the matrix using the specified rotation matrix and the translational part ...
AffineMatrix4x4T(const EulerAngles &rotation, const Vec3T< T > &translation=Vec3T< T >())
Create a matrix from Euler angles.
AffineMatrix4x4T< T > inverse() const
Quick inverse, transpose rotation part, and change sign of translation part.
AffineMatrix4x4T< T > & setTranslate(T tx, T ty, T tz)
Set the translational part of the matrix using the vector x, y, z.
AffineMatrix4x4T< T > & set(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21, T a22, T a23, T a30, T a31, T a32, T a33)
Set the entire matrix using values from the 16 elements using the following order:
void set(Real val, size_t i, size_t j)
Set the value of element i,j.
AffineMatrix4x4T< T > & preMultTranslate(const Vec3T< T > &v)
AffineMatrix4x4T< T > & setIdentity()
Set the value of the matrix to the identity matrix.
void mult(const AffineMatrix4x4T< T > &, const AffineMatrix4x4T< T > &)
bool operator!=(const AffineMatrix4x4T< T > &m) const
static AffineMatrix4x4T< T > rotate(T angle, const Vec3T< T > &axis)
Return a matrix which rotate angle radians around vector axis.
AffineMatrix4x4T< T > & operator=(const AffineMatrix4x4T< T > &rhs)=default
AffineMatrix4x4T< T > & setRotate(const Vec3T< T > &from, const Vec3T< T > &to)
Set the rotational part of the matrix using the specified two vectors.
AffineMatrix4x4T< T > & set(const QuatT< T > &q)
Set the rotational part of the matrix using the specified quaternion and the translational part to 0,...
agx::Vec3T< T > transformPoint(const agx::Vec3T< T > &point) const
Transforms a (mathematical) point, using both rotation and translation.
AffineMatrix4x4T(T a00, T a01, T a02, T a03, T a10, T a11, T a12, T a13, T a20, T a21, T a22, T a23, T a30, T a31, T a32, T a33)
Create a matrix from 16 T scalars.
AffineMatrix4x4T(const AffineMatrix4x4T &mat)=default
AffineMatrix4x4T< T > & postMultTranslate(const Vec3T< T > &v)
static AffineMatrix4x4T< T > translate(T x, T y, T z)
Return a matrix which translates according to vector [x,y,z].
void operator*=(const AffineMatrix4x4T< T > &other)
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Matrix class for affine transformations.
void mult(const Matrix4x4T< T > &, const Matrix4x4T< T > &)
Matrix4x4T< T > & setRotate(const QuatT< T > &q)
Matrix4x4T< T > & set(T const *const ptr)
bool isRigidTransformation() const
Specialized types of matrices for holding orthogonal transformation matrices.
The object holding quaternions and providing operations on these.
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,...
A class holding 3 dimensional vectors and providing basic arithmetic.
A class holding 4 dimensional vectors and providing basic arithmetic.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AffineMatrix4x4T< Real32 > AffineMatrix4x4f
Vec3T< T > operator*(const Vec3T< T > &v, const AffineMatrix4x4T< T > &m)
AffineMatrix4x4d inverse< AffineMatrix4x4d >(const AffineMatrix4x4d &value)
Real mult(const Jacobian6DOFElementT< T > &G1, const Jacobian6DOFElementT< T > &G2)
AffineMatrix4x4T< Real64 > AffineMatrix4x4d
static constexpr Real AGX_EQUIVALENT_EPSILON
AffineMatrix4x4T< Real > AffineMatrix4x4
AffineMatrix4x4f inverse< AffineMatrix4x4f >(const AffineMatrix4x4f &value)
AGXPHYSICS_EXPORT agx::Bool equivalent(const agx::AddedMassInteraction::Matrix6x6 &lhs, const agx::AddedMassInteraction::Matrix6x6 &rhs, agx::Real eps=agx::RealEpsilon)