AGX Dynamics  2.35.0.1
AffineMatrix4x4.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 
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 
157 
166 
167 
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 
279 
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 
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 
358 
363 
365  void multSSE(const AffineMatrix4x4T<T>& lhs, const AffineMatrix4x4T<T>& rhs);
368  void preMult( 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  {
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 
500  #if defined(__GNUC__) && !defined(__clang__)
501  #pragma GCC diagnostic push
502  #pragma GCC diagnostic ignored "-Wstringop-overflow"
503  #endif
504 
505  memcpy(this->m_data, ptr, sizeof(T)*16);
506 
507  #if defined(__GNUC__) && !defined(__clang__)
508  #pragma GCC diagnostic pop
509  #endif
510 
511  agxAssert(this->isRigidTransformation());
512  return *this;
513  }
514 
515 
516  template <typename T>
518  T a10, T a11, T a12, T a13,
519  T a20, T a21, T a22, T a23,
520  T a30, T a31, T a32, T a33 )
521  {
522 
523  Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
524  return *this;
525  }
526 
527  template <typename T>
529  {
530  this->setRotate(q);
531  this->setTranslate(0.0, 0.0, 0.0);
532 
533  return *this;
534  }
535 
536 
537  template <typename T>
539  {
540  this->setRotate(m3);
541  this->setTranslate(0.0, 0.0, 0.0);
542 
543  return *this;
544  }
545 
546  template <typename T>
548  {
550  return *this;
551  }
552 
553 
554  template <typename T>
556  {
557  (*this)(0,0) = (T)m3(0,0);
558  (*this)(0,1) = (T)m3(0,1);
559  (*this)(0,2) = (T)m3(0,2);
560 
561  (*this)(1,0) = (T)m3(1,0);
562  (*this)(1,1) = (T)m3(1,1);
563  (*this)(1,2) = (T)m3(1,2);
564 
565  (*this)(2,0) = (T)m3(2,0);
566  (*this)(2,1) = (T)m3(2,1);
567  (*this)(2,2) = (T)m3(2,2);
568 
569  return *this;
570  }
571 
572  template <typename T>
574  {
575  QuatT<T> quat;
576  quat.setRotate(from,to);
577  this->setRotate(quat);
578  return *this;
579  }
580 
581  template <typename T>
583  {
584  QuatT<T> quat;
585  quat.setRotate( angle, axis);
586  this->setRotate(quat);
587  return *this;
588  }
589 
590  template <typename T>
592  {
593  QuatT<T> quat;
594  quat.setRotate( angle, x, y, z);
595  this->setRotate(quat);
596  return *this;
597  }
598 
599  template <typename T>
601  T angle2, const Vec3T<T>& axis2,
602  T angle3, const Vec3T<T>& axis3 )
603  {
604  QuatT<T> quat;
605  quat.setRotate(angle1, axis1,
606  angle2, axis2,
607  angle3, axis3);
608  this->setRotate(quat);
609  return *this;
610  }
611 
612  template <typename T>
614  {
615  this->m_data[3][0] = t[0];
616  this->m_data[3][1] = t[1];
617  this->m_data[3][2] = t[2];
618 
619  return *this;
620  }
621 
622  template <typename T>
624  {
625  this->m_data[3][0] = tx;
626  this->m_data[3][1] = ty;
627  this->m_data[3][2] = tz;
628 
629  return *this;
630  }
631 
632 
633  template <typename T>
635  {
636  this->set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
637  return *this;
638  }
639 
640 
641  /*=====================================================
642  Static methods
643  =======================================================*/
644 
645  template <typename T>
647  {
648  return AffineMatrix4x4T<T>(
649  0, -vec.z(), vec.y(), 0,
650  vec.z(), 0, -vec.x(), 0,
651  -vec.y(), vec.x(), 0, 0,
652  0, 0, 0, 1);
653  }
654 
655 
656  template <typename T>
658  {
660  m.setTranslate(dv);
661  return m;
662  }
663 
664  template <typename T>
666  {
668  m.setTranslate(x, y, z);
669  return m;
670  }
671 
672  template <typename T>
674  {
676  m.setRotate(from, to);
677  return m;
678  }
679 
680  template <typename T>
681  inline AffineMatrix4x4T<T> AffineMatrix4x4T<T>::rotate( T angle, T x, T y, T z )
682  {
684  m.setRotate(angle, x, y, z);
685  return m;
686  }
687 
688  template <typename T>
690  {
692  m.setRotate(angle, axis);
693  return m;
694  }
695 
696  template <typename T>
698  T angle2, const Vec3T<T>& axis2,
699  T angle3, const Vec3T<T>& axis3 )
700  {
702  m.setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
703  return m;
704  }
705 
706 
707  /*=====================================================
708  Operators
709  =======================================================*/
710  template <typename T>
712  {
713  agx::prefetch<agx::L1>( lhs.m_data );
714  agx::prefetch<agx::L1>( rhs.m_data );
715 
716  if (&lhs==this)
717  {
718  postMult(rhs);
719  return;
720  }
721  if (&rhs==this)
722  {
723  preMult(lhs);
724  return;
725  }
726 
727  this->m_data[0][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 0);
728  this->m_data[0][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 1);
729  this->m_data[0][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 2);
730 
731  this->m_data[1][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 0);
732  this->m_data[1][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 1);
733  this->m_data[1][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 2);
734 
735  this->m_data[2][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 0);
736  this->m_data[2][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 1);
737  this->m_data[2][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 2);
738 
739  this->m_data[3][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 0) + rhs.m_data[3][0];
740  this->m_data[3][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 1) + rhs.m_data[3][1];
741  this->m_data[3][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 2) + rhs.m_data[3][2];
742 
743  }
744 
745  template <typename T>
747  {
748 
749  // more efficient method just use a T[4] for temporary storage.
750  T t[4];
751  for(size_t col=0; col<3; ++col) {
752  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 0, col );
753  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 1, col );
754  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 2, col );
755  t[3] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 3, col );
756  this->m_data[0][col] = t[0];
757  this->m_data[1][col] = t[1];
758  this->m_data[2][col] = t[2];
759  this->m_data[3][col] = t[3] + this->m_data[3][col];
760  }
761  }
762 
763  template <typename T>
765  {
766 
767  // more efficient method just use a T[3] for temporary storage.
768  T t[3];
769  for(size_t row=0; row<3; ++row)
770  {
771  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 0 );
772  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 1 );
773  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 2 );
774 
775  AGX_AFFINEMATRIX4X4_SET_ROW(row, t[0], t[1], t[2] )
776  }
777  // treat last row differently
778  t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 0 ) + other.m_data[3][0];
779  t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 1 ) + other.m_data[3][1];
780  t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 2 ) + other.m_data[3][2];
781  AGX_AFFINEMATRIX4X4_SET_ROW(3, t[0], t[1], t[2] )
782  }
783 
784  template <typename T>
786  {
787  for (unsigned i = 0; i < 3; ++i)
788  {
789  this->m_data[3][0] += v[i]*this->m_data[i][0];
790  this->m_data[3][1] += v[i]*this->m_data[i][1];
791  this->m_data[3][2] += v[i]*this->m_data[i][2];
792  this->m_data[3][3] += v[i]*this->m_data[i][3];
793  }
794  return *this;
795  }
796 
797  template <typename T>
799  {
800  for (unsigned i = 0; i < 3; ++i)
801  {
802  this->m_data[0][i] += v[i]*this->m_data[0][3];
803  this->m_data[1][i] += v[i]*this->m_data[1][3];
804  this->m_data[2][i] += v[i]*this->m_data[2][3];
805  this->m_data[3][i] += v[i]*this->m_data[3][3];
806  }
807  return *this;
808  }
809 
810 
811 
812  template <typename T>
814  {
815  if ( this != &rhs )
816  this->set( rhs.ptr() );
817 
818  return *this;
819  }
820 
821 
822  template <typename T>
824  {
826  r.mult( *this, m );
827  return r;
828  }
829 
830  template <typename T>
832  {
833  Matrix4x4T<T> r;
834  r.mult( *this, m );
835  return r;
836  }
837 
838 
839  template <typename T>
841  {
842  if ( this == &other )
843  {
844  AffineMatrix4x4T<T> temp( other );
845  postMult( temp );
846  }
847  else postMult( other );
848  }
849 
850 
851  template <typename T>
853  {
854  return postMult(v);
855  }
856 
857  template <typename T>
859  {
860  return postMult(v);
861  }
862 
863  template <typename T>
865  {
866  return m.preMult(v);
867  }
868  template <typename T>
869 
870 
872  {
873  return m.preMult(v);
874  }
875 
876 
877  template <typename T>
879  {
880  T x,y,z;
881 
882  // diagonal
883  this->m_data[0][0] = rhs.m_data[0][0];
884  this->m_data[1][1] = rhs.m_data[1][1];
885  this->m_data[2][2] = rhs.m_data[2][2];
886 
887  // rotation
888  this->m_data[0][1] = rhs.m_data[1][0];
889  this->m_data[1][0] = rhs.m_data[0][1];
890  this->m_data[0][2] = rhs.m_data[2][0];
891  this->m_data[2][0] = rhs.m_data[0][2];
892  this->m_data[1][2] = rhs.m_data[2][1];
893  this->m_data[2][1] = rhs.m_data[1][2];
894 
895  x = rhs.m_data[3][0];
896  y = rhs.m_data[3][1];
897  z = rhs.m_data[3][2];
898 
899  // translation
900  this->m_data[3][0] = -( x * this->m_data[0][0] + y* this->m_data[1][0] + z * this->m_data[2][0]);
901  this->m_data[3][1] = -( x * this->m_data[0][1] + y* this->m_data[1][1] + z * this->m_data[2][1]);
902  this->m_data[3][2] = -( x * this->m_data[0][2] + y* this->m_data[1][2] + z * this->m_data[2][2]);
903 
904  return true;
905  }
906 
907  template <typename T>
909  {
910  return
911  agx::equivalent(a(0, 0), b(0, 0), epsilon) &&
912  agx::equivalent(a(0, 1), b(0, 1), epsilon) &&
913  agx::equivalent(a(0, 2), b(0, 2), epsilon) &&
914  agx::equivalent(a(0, 3), b(0, 3), epsilon) &&
915  agx::equivalent(a(1, 0), b(1, 0), epsilon) &&
916  agx::equivalent(a(1, 1), b(1, 1), epsilon) &&
917  agx::equivalent(a(1, 2), b(1, 2), epsilon) &&
918  agx::equivalent(a(1, 3), b(1, 3), epsilon) &&
919  agx::equivalent(a(2, 0), b(2, 0), epsilon) &&
920  agx::equivalent(a(2, 1), b(2, 1), epsilon) &&
921  agx::equivalent(a(2, 2), b(2, 2), epsilon) &&
922  agx::equivalent(a(2, 3), b(2, 3), epsilon) &&
923  agx::equivalent(a(3, 0), b(3, 0), epsilon) &&
924  agx::equivalent(a(3, 1), b(3, 1), epsilon) &&
925  agx::equivalent(a(3, 2), b(3, 2), epsilon) &&
926  agx::equivalent(a(3, 3), b(3, 3), epsilon);
927  }
928 
929 
930  template <>
932  {
933  #if AGX_USE_SSE()
934  multSSE32Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
935  #else
936  mult(lhs, rhs);
937  #endif
938  }
939 
940  template <>
942  {
943  #if AGX_USE_SSE()
944  multSSE64Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
945  #else
946  mult(lhs, rhs);
947  #endif
948  }
949 
950 
951  template <>
953  {
954  return value.inverse();
955  }
956 
957 
958  template <>
960  {
961  return value.inverse();
962  }
963 
964 
965  template <typename T>
967  {
968  return Real((*this)(i,j));
969  }
970 
971  template <typename T>
972  AGX_FORCE_INLINE void AffineMatrix4x4T<T>::set(Real val, size_t i, size_t j)
973  {
974  (*this)(i,j) = T(val);
975  }
976 
977 
978  template <typename T>
980  {
981  return point * (*this);
982  }
983 
984  template <typename T>
986  {
987  return this->transform3x3(vector);
988  }
989 
990 
991 
992 }
993 
994 #include <agxData/Type.h>
995 
996 AGX_TYPE_BINDING(agx::AffineMatrix4x4f, "AffineMatrix4x4")
998 
999 #ifdef _MSC_VER
1000 # pragma warning(pop)
1001 #endif
1002 
1003 #endif
#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)
Definition: Type.h:179
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
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.
AffineMatrix4x4T< T > & set(const EulerAngles &euler)
Set the rotational part of the matrix using the specified euler angles and the translational part to ...
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...
Definition: EulerAngles.h:70
Matrix class for affine transformations.
Definition: Matrix4x4.h:56
void mult(const Matrix4x4T< T > &, const Matrix4x4T< T > &)
Definition: Matrix4x4.h:770
T m_data[4][4]
Definition: Matrix4x4.h:301
Matrix4x4T< T > & set(T const *const ptr)
Definition: Matrix4x4.h:483
Matrix4x4T< T > & setRotate(const QuatT< T > &q)
bool isRigidTransformation() const
Definition: Matrix4x4.h:453
Specialized types of matrices for holding orthogonal transformation matrices.
The object holding quaternions and providing operations on these.
Definition: QuatTemplate.h:57
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.
Definition: Vec3Template.h:46
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:35
#define agxAssert(expr)
Definition: debug.h:143
#define AGX_FORCE_INLINE
Definition: macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
AffineMatrix4x4T< Real32 > AffineMatrix4x4f
AffineMatrix4x4d inverse< AffineMatrix4x4d >(const AffineMatrix4x4d &value)
Real mult(const Jacobian6DOFElementT< T > &G1, const Jacobian6DOFElementT< T > &G2)
Definition: agx/Jacobian.h:386
double Real
Definition: Real.h:42
AffineMatrix4x4T< Real64 > AffineMatrix4x4d
Vec3T< T > operator*(const Vec3T< T > &v, const AffineMatrix4x4T< T > &m)
const Real AGX_EQUIVALENT_EPSILON
Definition: Math.h:57
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)