16#ifndef AGX_AFFINEMATRIX4X4_H
17#define AGX_AFFINEMATRIX4X4_H
21# pragma warning(disable: 4714)
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);
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)
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)
#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()
Creates a new matrix, initialized to be an identity matrix.
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.
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< T > & set(T const *const ptr)
Set the entire matrix using values from the array with 16 elements using the following order:
AffineMatrix4x4T< T > & operator=(const AffineMatrix4x4T< T > &rhs)
AffineMatrix4x4T(const AffineMatrix4x4T< T2 > &mat)
Copy constructor.
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 > & 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< 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
const 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)