AGX Dynamics 2.42.0.2
Loading...
Searching...
No Matches
AffineMatrix4x4.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16#pragma once
17
18#ifdef _MSC_VER
19# pragma warning(push)
20# pragma warning(disable: 4714) // Disable warnings about not able to force inline
21#endif
22
24#include <agx/Matrix4x4.h>
25
26
27namespace agx
28{
29 class EulerAngles;
30 class OrthoMatrix3x3;
31
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);
36
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])
41
50 template <typename T>
51 class AffineMatrix4x4T : public Matrix4x4T<T>
52 {
53 public:
54 /*=====================================================
55 Constructors
56 =======================================================*/
57
61 AffineMatrix4x4T() = default;
62
63#if !defined(SWIGJAVA)
64 AffineMatrix4x4T(const AffineMatrix4x4T& mat) = default;
65#endif
66
67#if !defined(SWIG)
69 template <typename T2, std::enable_if_t<std::is_same<T, T2>::value == 0, bool> = false >
71
72#endif
73
75 explicit AffineMatrix4x4T( T const * const ptr );
76
77
79 explicit AffineMatrix4x4T(const QuatT<T>& rotation, const Vec3T<T>& translation = Vec3T<T>());
80
82 explicit AffineMatrix4x4T( const EulerAngles& rotation, const Vec3T<T>& translation = Vec3T<T>());
83
85 explicit AffineMatrix4x4T( const OrthoMatrix3x3& rotation, const Vec3T<T>& translation = Vec3T<T>());
86
88 AffineMatrix4x4T( T a00, T a01, T a02, T a03,
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 );
92
93
95 ~AffineMatrix4x4T() = default;
96
97 /*=====================================================
98 Accessors
99 =======================================================*/
100
106
111
112
113 /*=====================================================
114 Mutators
115 =======================================================*/
116
132 AffineMatrix4x4T<T>& set(T const * const ptr);
133
134
150 AffineMatrix4x4T<T>& set(T a00, T a01, T a02, T a03,
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);
154
163
172
173
182
183
192
201
202
211
222
229 AffineMatrix4x4T<T>& setRotate(T angle, const Vec3T<T>& axis);
230
237 AffineMatrix4x4T<T>& setRotate(T angle, T x, T y, T z);
238
251 AffineMatrix4x4T<T>& setRotate(T angle1, const Vec3T<T>& axis1,
252 T angle2, const Vec3T<T>& axis2,
253 T angle3, const Vec3T<T>& axis3);
254
261
268
274
275
276
277 /*=====================================================
278 Static methods
279 =======================================================*/
280
285
292
300 static AffineMatrix4x4T<T> translate( T x, T y, T z );
301
308 static AffineMatrix4x4T<T> rotate( const Vec3T<T>& from, const Vec3T<T>& to );
309
318 static AffineMatrix4x4T<T> rotate( T angle, T x, T y, T z );
319
326 static AffineMatrix4x4T<T> rotate( T angle, const Vec3T<T>& axis );
327
340 static AffineMatrix4x4T<T> rotate( T angle1, const Vec3T<T>& axis1,
341 T angle2, const Vec3T<T>& axis2,
342 T angle3, const Vec3T<T>& axis3 );
344
345
346 /*=====================================================
347 Operators
348 =======================================================*/
349
353 Vec3T<T> operator* ( const Vec3T<T>& v ) const;
354 Vec4T<T> operator* ( const Vec4T<T>& v ) const;
355
356 void operator*= ( const AffineMatrix4x4T<T>& other );
357 bool operator== ( const AffineMatrix4x4T<T>& m ) const;
358 bool operator!= ( const AffineMatrix4x4T<T>& m ) const;
359
364
369
371 void multSSE(const AffineMatrix4x4T<T>& lhs, const AffineMatrix4x4T<T>& rhs);
378
380 Real at(size_t i, size_t j) const;
381
383 void set(Real val, size_t i, size_t j);
384
385 protected:
386 bool invert( const AffineMatrix4x4T<T>& rhs );
387 };
388
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");
391
393
396}
397
398
399
400/* ****************************************** */
401/* * IMPLEMENTATION ** */
402/* ****************************************** */
403#include <agx/OrthoMatrix3x3.h>
404#include <agx/EulerAngles.h>
405
406namespace agx
407{
408
409 /*=====================================================
410 Constructors
411 =======================================================*/
412
413#if !defined(SWIG)
414 template <typename T> template <typename T2, std::enable_if_t<std::is_same<T, T2>::value == 0, bool> >
416 {
417 }
418#endif
419
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)
425 {
427 }
428
429 template <typename T>
431 {
432 set( ptr );
433 }
434
435
436 template <typename T>
437 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(const QuatT<T>& rotation, const Vec3T<T>& translation) : Matrix4x4T<T>(rotation, translation)
438 {
439 }
440
441 template <typename T>
442 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T( const OrthoMatrix3x3& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
443 {
444 }
445
446 template <typename T>
447 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(agx::EulerAngles const& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
448 {
449 }
450
451
452
453 /*=====================================================
454 Queries
455 =======================================================*/
456
457
458 template <typename T>
460 {
462 m.invert( *this );
463 return m;
464 }
465
466 template <typename T>
468 {
469 T x = this->m_data[3][0];
470 T y = this->m_data[3][1];
471 T z = this->m_data[3][2];
472
473 Vec3T<T> invTranslate;
474
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]);
478
479 return invTranslate;
480 }
481
482 template <typename T>
484 {
485 const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
486 return (bitCompare == 0);
487 }
488
489 template <typename T>
491 {
492 const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
493 return (bitCompare != 0);
494 }
495
496
497 /*=====================================================
498 Setters
499 =======================================================*/
500 template <typename T>
502 {
503
504 #if defined(__GNUC__) && !defined(__clang__)
505 #pragma GCC diagnostic push
506 #pragma GCC diagnostic ignored "-Wstringop-overflow"
507 #endif
508
509 memcpy(this->m_data, ptr, sizeof(T)*16);
510
511 #if defined(__GNUC__) && !defined(__clang__)
512 #pragma GCC diagnostic pop
513 #endif
514
515 agxAssert(this->isRigidTransformation());
516 return *this;
517 }
518
519
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 )
525 {
526
527 Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
528 return *this;
529 }
530
531 template <typename T>
533 {
534 this->setRotate(q);
535 this->setTranslate(0.0, 0.0, 0.0);
536
537 return *this;
538 }
539
540
541 template <typename T>
543 {
544 this->setRotate(m3);
545 this->setTranslate(0.0, 0.0, 0.0);
546
547 return *this;
548 }
549
550 template <typename T>
552 {
554 return *this;
555 }
556
557
558 template <typename T>
560 {
561 (*this)(0,0) = (T)m3(0,0);
562 (*this)(0,1) = (T)m3(0,1);
563 (*this)(0,2) = (T)m3(0,2);
564
565 (*this)(1,0) = (T)m3(1,0);
566 (*this)(1,1) = (T)m3(1,1);
567 (*this)(1,2) = (T)m3(1,2);
568
569 (*this)(2,0) = (T)m3(2,0);
570 (*this)(2,1) = (T)m3(2,1);
571 (*this)(2,2) = (T)m3(2,2);
572
573 return *this;
574 }
575
576 template <typename T>
578 {
579 QuatT<T> quat;
580 quat.setRotate(from,to);
581 this->setRotate(quat);
582 return *this;
583 }
584
585 template <typename T>
587 {
588 QuatT<T> quat;
589 quat.setRotate( angle, axis);
590 this->setRotate(quat);
591 return *this;
592 }
593
594 template <typename T>
596 {
597 QuatT<T> quat;
598 quat.setRotate( angle, x, y, z);
599 this->setRotate(quat);
600 return *this;
601 }
602
603 template <typename T>
605 T angle2, const Vec3T<T>& axis2,
606 T angle3, const Vec3T<T>& axis3 )
607 {
608 QuatT<T> quat;
609 quat.setRotate(angle1, axis1,
610 angle2, axis2,
611 angle3, axis3);
612 this->setRotate(quat);
613 return *this;
614 }
615
616 template <typename T>
618 {
619 this->m_data[3][0] = t[0];
620 this->m_data[3][1] = t[1];
621 this->m_data[3][2] = t[2];
622
623 return *this;
624 }
625
626 template <typename T>
628 {
629 this->m_data[3][0] = tx;
630 this->m_data[3][1] = ty;
631 this->m_data[3][2] = tz;
632
633 return *this;
634 }
635
636
637 template <typename T>
639 {
640 this->set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
641 return *this;
642 }
643
644
645 /*=====================================================
646 Static methods
647 =======================================================*/
648
649 template <typename T>
651 {
652 return AffineMatrix4x4T<T>(
653 0, -vec.z(), vec.y(), 0,
654 vec.z(), 0, -vec.x(), 0,
655 -vec.y(), vec.x(), 0, 0,
656 0, 0, 0, 1);
657 }
658
659
660 template <typename T>
662 {
664 m.setTranslate(dv);
665 return m;
666 }
667
668 template <typename T>
670 {
672 m.setTranslate(x, y, z);
673 return m;
674 }
675
676 template <typename T>
678 {
680 m.setRotate(from, to);
681 return m;
682 }
683
684 template <typename T>
685 inline AffineMatrix4x4T<T> AffineMatrix4x4T<T>::rotate( T angle, T x, T y, T z )
686 {
688 m.setRotate(angle, x, y, z);
689 return m;
690 }
691
692 template <typename T>
694 {
696 m.setRotate(angle, axis);
697 return m;
698 }
699
700 template <typename T>
702 T angle2, const Vec3T<T>& axis2,
703 T angle3, const Vec3T<T>& axis3 )
704 {
706 m.setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
707 return m;
708 }
709
710
711 /*=====================================================
712 Operators
713 =======================================================*/
714 template <typename T>
716 {
717 agx::prefetch<agx::L1>( lhs.m_data );
718 agx::prefetch<agx::L1>( rhs.m_data );
719
720 if (&lhs==this)
721 {
722 postMult(rhs);
723 return;
724 }
725 if (&rhs==this)
726 {
727 preMult(lhs);
728 return;
729 }
730
731 this->m_data[0][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 0);
732 this->m_data[0][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 1);
733 this->m_data[0][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 2);
734
735 this->m_data[1][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 0);
736 this->m_data[1][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 1);
737 this->m_data[1][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 2);
738
739 this->m_data[2][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 0);
740 this->m_data[2][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 1);
741 this->m_data[2][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 2);
742
743 this->m_data[3][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 0) + rhs.m_data[3][0];
744 this->m_data[3][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 1) + rhs.m_data[3][1];
745 this->m_data[3][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 2) + rhs.m_data[3][2];
746
747 }
748
749 template <typename T>
751 {
752
753 // more efficient method just use a T[4] for temporary storage.
754 T t[4];
755 for(size_t col=0; col<3; ++col) {
756 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 0, col );
757 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 1, col );
758 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 2, col );
759 t[3] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 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];
764 }
765 }
766
767 template <typename T>
769 {
770
771 // more efficient method just use a T[3] for temporary storage.
772 T t[3];
773 for(size_t row=0; row<3; ++row)
774 {
775 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 0 );
776 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 1 );
777 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 2 );
778
779 AGX_AFFINEMATRIX4X4_SET_ROW(row, t[0], t[1], t[2] )
780 }
781 // treat last row differently
782 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 0 ) + other.m_data[3][0];
783 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 1 ) + other.m_data[3][1];
784 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 2 ) + other.m_data[3][2];
785 AGX_AFFINEMATRIX4X4_SET_ROW(3, t[0], t[1], t[2] )
786 }
787
788 template <typename T>
790 {
791 for (unsigned i = 0; i < 3; ++i)
792 {
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];
797 }
798 return *this;
799 }
800
801 template <typename T>
803 {
804 for (unsigned i = 0; i < 3; ++i)
805 {
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];
810 }
811 return *this;
812 }
813
814 template <typename T>
816 {
818 r.mult( *this, m );
819 return r;
820 }
821
822 template <typename T>
824 {
826 r.mult( *this, m );
827 return r;
828 }
829
830
831 template <typename T>
833 {
834 if ( this == &other )
835 {
836 AffineMatrix4x4T<T> temp( other );
837 postMult( temp );
838 }
839 else postMult( other );
840 }
841
842
843 template <typename T>
845 {
846 return postMult(v);
847 }
848
849 template <typename T>
851 {
852 return postMult(v);
853 }
854
855 template <typename T>
857 {
858 return m.preMult(v);
859 }
860 template <typename T>
861
862
864 {
865 return m.preMult(v);
866 }
867
868
869 template <typename T>
871 {
872 T x,y,z;
873
874 // diagonal
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];
878
879 // rotation
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];
886
887 x = rhs.m_data[3][0];
888 y = rhs.m_data[3][1];
889 z = rhs.m_data[3][2];
890
891 // translation
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]);
895
896 return true;
897 }
898
899 template <typename T>
901 {
902 return
903 agx::equivalent(a(0, 0), b(0, 0), epsilon) &&
904 agx::equivalent(a(0, 1), b(0, 1), epsilon) &&
905 agx::equivalent(a(0, 2), b(0, 2), epsilon) &&
906 agx::equivalent(a(0, 3), b(0, 3), epsilon) &&
907 agx::equivalent(a(1, 0), b(1, 0), epsilon) &&
908 agx::equivalent(a(1, 1), b(1, 1), epsilon) &&
909 agx::equivalent(a(1, 2), b(1, 2), epsilon) &&
910 agx::equivalent(a(1, 3), b(1, 3), epsilon) &&
911 agx::equivalent(a(2, 0), b(2, 0), epsilon) &&
912 agx::equivalent(a(2, 1), b(2, 1), epsilon) &&
913 agx::equivalent(a(2, 2), b(2, 2), epsilon) &&
914 agx::equivalent(a(2, 3), b(2, 3), epsilon) &&
915 agx::equivalent(a(3, 0), b(3, 0), epsilon) &&
916 agx::equivalent(a(3, 1), b(3, 1), epsilon) &&
917 agx::equivalent(a(3, 2), b(3, 2), epsilon) &&
918 agx::equivalent(a(3, 3), b(3, 3), epsilon);
919 }
920
921
922 template <>
924 {
925 #if AGX_USE_SSE()
926 multSSE32Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
927 #else
928 mult(lhs, rhs);
929 #endif
930 }
931
932 template <>
934 {
935 #if AGX_USE_SSE()
936 multSSE64Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
937 #else
938 mult(lhs, rhs);
939 #endif
940 }
941
942
943 template <>
945 {
946 return value.inverse();
947 }
948
949
950 template <>
952 {
953 return value.inverse();
954 }
955
956
957 template <typename T>
959 {
960 return Real((*this)(i,j));
961 }
962
963 template <typename T>
964 AGX_FORCE_INLINE void AffineMatrix4x4T<T>::set(Real val, size_t i, size_t j)
965 {
966 (*this)(i,j) = T(val);
967 }
968
969
970 template <typename T>
972 {
973 return point * (*this);
974 }
975
976 template <typename T>
978 {
979 return this->transform3x3(vector);
980 }
981
982
983
984}
985
986#include <agxData/Type.h>
987
988AGX_TYPE_BINDING(agx::AffineMatrix4x4f, "AffineMatrix4x4")
989AGX_TYPE_BINDING(agx::AffineMatrix4x4d, "AffineMatrix4x4")
990
991#ifdef _MSC_VER
992# pragma warning(pop)
993#endif
994
#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
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...
Definition: EulerAngles.h:70
Matrix class for affine transformations.
Definition: Matrix4x4.h:58
void mult(const Matrix4x4T< T > &, const Matrix4x4T< T > &)
Definition: Matrix4x4.h:781
T m_data[4][4]
Definition: Matrix4x4.h:310
Matrix4x4T< T > & setRotate(const QuatT< T > &q)
Matrix4x4T< T > & set(T const *const ptr)
Definition: Matrix4x4.h:494
bool isRigidTransformation() const
Definition: Matrix4x4.h:464
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
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)
Definition: agx/Jacobian.h:386
double Real
Definition: Real.h:41
AffineMatrix4x4T< Real64 > AffineMatrix4x4d
static constexpr 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)