AGXDynamics  2.31.1.0
AffineMatrix4x4.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 #ifndef AGX_AFFINEMATRIX4X4_H
17 #define AGX_AFFINEMATRIX4X4_H
18 
19 #ifdef _MSC_VER
20 # pragma warning(push)
21 # pragma warning(disable: 4714) // Disable warnings about not able to force inline
22 #endif
23 
24 #include <agx/config/AGX_USE_SSE.h>
25 #include <agx/Matrix4x4.h>
26 
27 
28 namespace agx
29 {
30  class EulerAngles;
31  class OrthoMatrix3x3;
32 
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);
37 
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])
42 
51  template <typename T>
52  class AffineMatrix4x4T : public Matrix4x4T<T>
53  {
54  public:
55  /*=====================================================
56  Constructors
57  =======================================================*/
58 
63 
65  template <typename T2>
66  explicit AffineMatrix4x4T( const AffineMatrix4x4T<T2>& mat );
67 
69  explicit AffineMatrix4x4T( T const * const ptr );
70 
71 
73  explicit AffineMatrix4x4T(const QuatT<T>& rotation, const Vec3T<T>& translation = Vec3T<T>());
74 
76  explicit AffineMatrix4x4T( const EulerAngles& rotation, const Vec3T<T>& translation = Vec3T<T>());
77 
79  explicit AffineMatrix4x4T( const OrthoMatrix3x3& rotation, const Vec3T<T>& translation = Vec3T<T>());
80 
82  AffineMatrix4x4T( T a00, T a01, T a02, T a03,
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 );
86 
87 
89  ~AffineMatrix4x4T() = default;
90 
91  /*=====================================================
92  Accessors
93  =======================================================*/
94 
100 
104  Vec3T<T> getInvTranslate() const;
105 
106 
107  /*=====================================================
108  Mutators
109  =======================================================*/
110 
126  AffineMatrix4x4T<T>& set(T const * const ptr);
127 
128 
144  AffineMatrix4x4T<T>& set(T a00, T a01, T a02, T a03,
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);
148 
156  AffineMatrix4x4T<T>& set(const QuatT<T>& q);
157 
165  AffineMatrix4x4T<T>& set(const OrthoMatrix3x3& m3);
166 
167 
175  AffineMatrix4x4T<T>& set(const EulerAngles& euler);
176 
177 
186 
195 
196 
205 
215  AffineMatrix4x4T<T>& setRotate(const Vec3T<T>& from, const Vec3T<T>& to);
216 
223  AffineMatrix4x4T<T>& setRotate(T angle, const Vec3T<T>& axis);
224 
231  AffineMatrix4x4T<T>& setRotate(T angle, T x, T y, T z);
232 
245  AffineMatrix4x4T<T>& setRotate(T angle1, const Vec3T<T>& axis1,
246  T angle2, const Vec3T<T>& axis2,
247  T angle3, const Vec3T<T>& axis3);
248 
255 
261  AffineMatrix4x4T<T>& setTranslate(T tx, T ty, T tz);
262 
268 
269 
270 
271  /*=====================================================
272  Static methods
273  =======================================================*/
274 
278  static AffineMatrix4x4T<T> crossMatrix(const Vec3T<T>& vec);
279 
285  static AffineMatrix4x4T<T> translate( const Vec3T<T>& dv );
286 
294  static AffineMatrix4x4T<T> translate( T x, T y, T z );
295 
302  static AffineMatrix4x4T<T> rotate( const Vec3T<T>& from, const Vec3T<T>& to );
303 
312  static AffineMatrix4x4T<T> rotate( T angle, T x, T y, T z );
313 
320  static AffineMatrix4x4T<T> rotate( T angle, const Vec3T<T>& axis );
321 
334  static AffineMatrix4x4T<T> rotate( T angle1, const Vec3T<T>& axis1,
335  T angle2, const Vec3T<T>& axis2,
336  T angle3, const Vec3T<T>& axis3 );
337  static AffineMatrix4x4T<T> rotate(const EulerAngles& euler);
338 
339 
340  /*=====================================================
341  Operators
342  =======================================================*/
343 
345  Matrix4x4T<T> operator* ( const Matrix4x4T<T> &m ) const;
347  Vec3T<T> operator* ( const Vec3T<T>& v ) const;
348  Vec4T<T> operator* ( const Vec4T<T>& v ) const;
349 
350  void operator*= ( const AffineMatrix4x4T<T>& other );
351  bool operator== ( const AffineMatrix4x4T<T>& m ) const;
352  bool operator!= ( const AffineMatrix4x4T<T>& m ) const;
353 
357  agx::Vec3T<T> transformPoint(const agx::Vec3T<T>& point) const;
358 
362  agx::Vec3T<T> transformVector(const agx::Vec3T<T>& vector) const;
363 
364  void mult( const AffineMatrix4x4T<T>&, const AffineMatrix4x4T<T>& );
365  void multSSE(const AffineMatrix4x4T<T>& lhs, const AffineMatrix4x4T<T>& rhs);
368  void preMult( const AffineMatrix4x4T<T>& );
369  void postMult( const AffineMatrix4x4T<T>& );
372 
374  Real at(size_t i, size_t j) const;
375 
377  void set(Real val, size_t i, size_t j);
378 
379  protected:
380  bool invert( const AffineMatrix4x4T<T>& rhs );
381  };
382 
383 
385 
388 }
389 
390 
391 
392 /* ****************************************** */
393 /* * IMPLEMENTATION ** */
394 /* ****************************************** */
395 #include <agx/OrthoMatrix3x3.h>
396 #include <agx/EulerAngles.h>
397 
398 namespace agx
399 {
400 
401  /*=====================================================
402  Constructors
403  =======================================================*/
404 
405  template <typename T>
407  {
408  this->setIdentity();
409  }
410 
411  template <typename T> template <typename T2>
413  {
414  }
415 
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)
421  {
422  agxAssert(this->isRigidTransformation());
423  }
424 
425  template <typename T>
427  {
428  set( ptr );
429  }
430 
431 
432  template <typename T>
433  AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(const QuatT<T>& rotation, const Vec3T<T>& translation) : Matrix4x4T<T>(rotation, translation)
434  {
435  }
436 
437  template <typename T>
438  AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T( const OrthoMatrix3x3& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
439  {
440  }
441 
442  template <typename T>
443  AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(agx::EulerAngles const& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
444  {
445  }
446 
447 
448 
449  /*=====================================================
450  Queries
451  =======================================================*/
452 
453 
454  template <typename T>
456  {
458  m.invert( *this );
459  return m;
460  }
461 
462  template <typename T>
464  {
465  T x = this->m_data[3][0];
466  T y = this->m_data[3][1];
467  T z = this->m_data[3][2];
468 
469  Vec3T<T> invTranslate;
470 
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]);
474 
475  return invTranslate;
476  }
477 
478  template <typename T>
480  {
481  const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
482  return (bitCompare == 0);
483  }
484 
485  template <typename T>
487  {
488  const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
489  return (bitCompare != 0);
490  }
491 
492 
493  /*=====================================================
494  Setters
495  =======================================================*/
496  template <typename T>
498  {
499  memcpy(this->m_data, ptr, sizeof(T)*16);
500  agxAssert(this->isRigidTransformation());
501  return *this;
502  }
503 
504 
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 )
510  {
511 
512  Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
513  return *this;
514  }
515 
516  template <typename T>
518  {
519  this->setRotate(q);
520  this->setTranslate(0.0, 0.0, 0.0);
521 
522  return *this;
523  }
524 
525 
526  template <typename T>
528  {
529  this->setRotate(m3);
530  this->setTranslate(0.0, 0.0, 0.0);
531 
532  return *this;
533  }
534 
535  template <typename T>
537  {
539  return *this;
540  }
541 
542 
543  template <typename T>
545  {
546  (*this)(0,0) = (T)m3(0,0);
547  (*this)(0,1) = (T)m3(0,1);
548  (*this)(0,2) = (T)m3(0,2);
549 
550  (*this)(1,0) = (T)m3(1,0);
551  (*this)(1,1) = (T)m3(1,1);
552  (*this)(1,2) = (T)m3(1,2);
553 
554  (*this)(2,0) = (T)m3(2,0);
555  (*this)(2,1) = (T)m3(2,1);
556  (*this)(2,2) = (T)m3(2,2);
557 
558  return *this;
559  }
560 
561  template <typename T>
563  {
564  QuatT<T> quat;
565  quat.setRotate(from,to);
566  this->setRotate(quat);
567  return *this;
568  }
569 
570  template <typename T>
572  {
573  QuatT<T> quat;
574  quat.setRotate( angle, axis);
575  this->setRotate(quat);
576  return *this;
577  }
578 
579  template <typename T>
581  {
582  QuatT<T> quat;
583  quat.setRotate( angle, x, y, z);
584  this->setRotate(quat);
585  return *this;
586  }
587 
588  template <typename T>
590  T angle2, const Vec3T<T>& axis2,
591  T angle3, const Vec3T<T>& axis3 )
592  {
593  QuatT<T> quat;
594  quat.setRotate(angle1, axis1,
595  angle2, axis2,
596  angle3, axis3);
597  this->setRotate(quat);
598  return *this;
599  }
600 
601  template <typename T>
603  {
604  this->m_data[3][0] = t[0];
605  this->m_data[3][1] = t[1];
606  this->m_data[3][2] = t[2];
607 
608  return *this;
609  }
610 
611  template <typename T>
613  {
614  this->m_data[3][0] = tx;
615  this->m_data[3][1] = ty;
616  this->m_data[3][2] = tz;
617 
618  return *this;
619  }
620 
621 
622  template <typename T>
624  {
625  this->set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
626  return *this;
627  }
628 
629 
630  /*=====================================================
631  Static methods
632  =======================================================*/
633 
634  template <typename T>
636  {
637  return AffineMatrix4x4T<T>(
638  0, -vec.z(), vec.y(), 0,
639  vec.z(), 0, -vec.x(), 0,
640  -vec.y(), vec.x(), 0, 0,
641  0, 0, 0, 1);
642  }
643 
644 
645  template <typename T>
647  {
649  m.setTranslate(dv);
650  return m;
651  }
652 
653  template <typename T>
655  {
657  m.setTranslate(x, y, z);
658  return m;
659  }
660 
661  template <typename T>
663  {
665  m.setRotate(from, to);
666  return m;
667  }
668 
669  template <typename T>
670  inline AffineMatrix4x4T<T> AffineMatrix4x4T<T>::rotate( T angle, T x, T y, T z )
671  {
673  m.setRotate(angle, x, y, z);
674  return m;
675  }
676 
677  template <typename T>
679  {
681  m.setRotate(angle, axis);
682  return m;
683  }
684 
685  template <typename T>
687  T angle2, const Vec3T<T>& axis2,
688  T angle3, const Vec3T<T>& axis3 )
689  {
691  m.setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
692  return m;
693  }
694 
695 
696  /*=====================================================
697  Operators
698  =======================================================*/
699  template <typename T>
701  {
702  agx::prefetch<agx::L1>( lhs.m_data );
703  agx::prefetch<agx::L1>( rhs.m_data );
704 
705  if (&lhs==this)
706  {
707  postMult(rhs);
708  return;
709  }
710  if (&rhs==this)
711  {
712  preMult(lhs);
713  return;
714  }
715 
716  this->m_data[0][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 0);
717  this->m_data[0][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 1);
718  this->m_data[0][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 2);
719 
720  this->m_data[1][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 0);
721  this->m_data[1][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 1);
722  this->m_data[1][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 2);
723 
724  this->m_data[2][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 0);
725  this->m_data[2][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 1);
726  this->m_data[2][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 2);
727 
728  this->m_data[3][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 0) + rhs.m_data[3][0];
729  this->m_data[3][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 1) + rhs.m_data[3][1];
730  this->m_data[3][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 2) + rhs.m_data[3][2];
731 
732  }
733 
734  template <typename T>
736  {
737 
738  // more efficient method just use a T[4] for temporary storage.
739  T t[4];
740  for(size_t col=0; col<3; ++col) {
741  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 0, col );
742  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 1, col );
743  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 2, col );
744  t[3] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 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];
749  }
750  }
751 
752  template <typename T>
754  {
755 
756  // more efficient method just use a T[3] for temporary storage.
757  T t[3];
758  for(size_t row=0; row<3; ++row)
759  {
760  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 0 );
761  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 1 );
762  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 2 );
763 
764  AGX_AFFINEMATRIX4X4_SET_ROW(row, t[0], t[1], t[2] )
765  }
766  // treat last row differently
767  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 0 ) + other.m_data[3][0];
768  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 1 ) + other.m_data[3][1];
769  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 2 ) + other.m_data[3][2];
770  AGX_AFFINEMATRIX4X4_SET_ROW(3, t[0], t[1], t[2] )
771  }
772 
773  template <typename T>
775  {
776  for (unsigned i = 0; i < 3; ++i)
777  {
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];
782  }
783  return *this;
784  }
785 
786  template <typename T>
788  {
789  for (unsigned i = 0; i < 3; ++i)
790  {
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];
795  }
796  return *this;
797  }
798 
799 
800 
801  template <typename T>
803  {
804  if ( this != &rhs )
805  this->set( rhs.ptr() );
806 
807  return *this;
808  }
809 
810 
811  template <typename T>
813  {
815  r.mult( *this, m );
816  return r;
817  }
818 
819  template <typename T>
821  {
822  Matrix4x4T<T> r;
823  r.mult( *this, m );
824  return r;
825  }
826 
827 
828  template <typename T>
830  {
831  if ( this == &other )
832  {
833  AffineMatrix4x4T<T> temp( other );
834  postMult( temp );
835  }
836  else postMult( other );
837  }
838 
839 
840  template <typename T>
842  {
843  return postMult(v);
844  }
845 
846  template <typename T>
848  {
849  return postMult(v);
850  }
851 
852  template <typename T>
854  {
855  return m.preMult(v);
856  }
857  template <typename T>
858 
859 
861  {
862  return m.preMult(v);
863  }
864 
865 
866  template <typename T>
868  {
869  T x,y,z;
870 
871  // diagonal
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];
875 
876  // rotation
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];
883 
884  x = rhs.m_data[3][0];
885  y = rhs.m_data[3][1];
886  z = rhs.m_data[3][2];
887 
888  // translation
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]);
892 
893  return true;
894  }
895 
896  template <typename T>
898  {
899  return
900  agx::equivalent(a(0, 0), b(0, 0), epsilon) &&
901  agx::equivalent(a(0, 1), b(0, 1), epsilon) &&
902  agx::equivalent(a(0, 2), b(0, 2), epsilon) &&
903  agx::equivalent(a(0, 3), b(0, 3), epsilon) &&
904  agx::equivalent(a(1, 0), b(1, 0), epsilon) &&
905  agx::equivalent(a(1, 1), b(1, 1), epsilon) &&
906  agx::equivalent(a(1, 2), b(1, 2), epsilon) &&
907  agx::equivalent(a(1, 3), b(1, 3), epsilon) &&
908  agx::equivalent(a(2, 0), b(2, 0), epsilon) &&
909  agx::equivalent(a(2, 1), b(2, 1), epsilon) &&
910  agx::equivalent(a(2, 2), b(2, 2), epsilon) &&
911  agx::equivalent(a(2, 3), b(2, 3), epsilon) &&
912  agx::equivalent(a(3, 0), b(3, 0), epsilon) &&
913  agx::equivalent(a(3, 1), b(3, 1), epsilon) &&
914  agx::equivalent(a(3, 2), b(3, 2), epsilon) &&
915  agx::equivalent(a(3, 3), b(3, 3), epsilon);
916  }
917 
918 
919  template <>
921  {
922  #if AGX_USE_SSE()
923  multSSE32Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
924  #else
925  mult(lhs, rhs);
926  #endif
927  }
928 
929  template <>
931  {
932  #if AGX_USE_SSE()
933  multSSE64Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
934  #else
935  mult(lhs, rhs);
936  #endif
937  }
938 
939 
940  template <>
942  {
943  return value.inverse();
944  }
945 
946 
947  template <>
949  {
950  return value.inverse();
951  }
952 
953 
954  template <typename T>
956  {
957  return Real((*this)(i,j));
958  }
959 
960  template <typename T>
961  AGX_FORCE_INLINE void AffineMatrix4x4T<T>::set(Real val, size_t i, size_t j)
962  {
963  (*this)(i,j) = T(val);
964  }
965 
966 
967  template <typename T>
969  {
970  return point * (*this);
971  }
972 
973  template <typename T>
975  {
976  return this->transform3x3(vector);
977  }
978 
979 
980 
981 }
982 
983 #include <agxData/Type.h>
984 
985 AGX_TYPE_BINDING(agx::AffineMatrix4x4f, "AffineMatrix4x4")
986 AGX_TYPE_BINDING(agx::AffineMatrix4x4d, "AffineMatrix4x4")
987 
988 #ifdef _MSC_VER
989 # pragma warning(pop)
990 #endif
991 
992 #endif
Real mult(const Jacobian6DOFElementT< T > &G1, const Jacobian6DOFElementT< T > &G2)
Definition: Jacobian.h:386
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.
Definition: Vec4Template.h:34
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)
Definition: agx.h:191
#define AGX_TYPE_BINDING(_Type, _Name)
Definition: Type.h:179
Vec4T< T > operator*(const Vec4T< T > &v, const AffineMatrix4x4T< T > &m)
Matrix class for affine transformations.
Definition: EulerAngles.h:36
AffineMatrix4x4d inverse< AffineMatrix4x4d >(const AffineMatrix4x4d &value)
const Real AGX_EQUIVALENT_EPSILON
Definition: Math.h:55
AffineMatrix4x4T()
Creates a new matrix, initialized to be an identity matrix.
void multSSE(const AffineMatrix4x4T< T > &lhs, const AffineMatrix4x4T< T > &rhs)
#define AGX_FORCE_INLINE
Definition: Object.h:63
agx::Vec3T< T > transformVector(const agx::Vec3T< T > &vector) const
Transforms a (mathematical) vector, using only rotation.
T inverse(const T &value)
Definition: Math.h:76
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...
Definition: EulerAngles.h:72
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.
Definition: QuatTemplate.h:56
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 > &)
Definition: Matrix4x4.h:770
#define agxAssert(expr)
Definition: debug.h:143
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.
Definition: Vec3Template.h:45
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)
Definition: agx.h:197
AffineMatrix4x4T< T > & postMultTranslate(const Vec3T< T > &v)
double Real
Definition: Real.h:42
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.
T m_data[4][4]
Definition: Matrix4x4.h:301
Specialized types of matrices for holding orthogonal transformation matrices.