AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
AffineMatrix4x4.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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#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
28namespace 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
64
65#if defined(SWIG) && !defined(SWIGJAVA)
66 explicit AffineMatrix4x4T(const AffineMatrix4x4T& mat);
67#else
69 template <typename T2>
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
391
394}
395
396
397
398/* ****************************************** */
399/* * IMPLEMENTATION ** */
400/* ****************************************** */
401#include <agx/OrthoMatrix3x3.h>
402#include <agx/EulerAngles.h>
403
404namespace agx
405{
406
407 /*=====================================================
408 Constructors
409 =======================================================*/
410
411 template <typename T>
413 {
414 this->setIdentity();
415 }
416
417 template <typename T> template <typename T2>
421
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)
427 {
429 }
430
431 template <typename T>
433 {
434 set( ptr );
435 }
436
437
438 template <typename T>
439 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(const QuatT<T>& rotation, const Vec3T<T>& translation) : Matrix4x4T<T>(rotation, translation)
440 {
441 }
442
443 template <typename T>
444 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T( const OrthoMatrix3x3& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
445 {
446 }
447
448 template <typename T>
449 AGX_FORCE_INLINE AffineMatrix4x4T<T>::AffineMatrix4x4T(agx::EulerAngles const& rotation, const Vec3T<T>& translation ) : Matrix4x4T<T>(rotation, translation)
450 {
451 }
452
453
454
455 /*=====================================================
456 Queries
457 =======================================================*/
458
459
460 template <typename T>
462 {
464 m.invert( *this );
465 return m;
466 }
467
468 template <typename T>
470 {
471 T x = this->m_data[3][0];
472 T y = this->m_data[3][1];
473 T z = this->m_data[3][2];
474
475 Vec3T<T> invTranslate;
476
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]);
480
481 return invTranslate;
482 }
483
484 template <typename T>
486 {
487 const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
488 return (bitCompare == 0);
489 }
490
491 template <typename T>
493 {
494 const int bitCompare = memcmp(this->m_data, m.m_data, sizeof(this->m_data));
495 return (bitCompare != 0);
496 }
497
498
499 /*=====================================================
500 Setters
501 =======================================================*/
502 template <typename T>
504 {
505
506 #if defined(__GNUC__) && !defined(__clang__)
507 #pragma GCC diagnostic push
508 #pragma GCC diagnostic ignored "-Wstringop-overflow"
509 #endif
510
511 memcpy(this->m_data, ptr, sizeof(T)*16);
512
513 #if defined(__GNUC__) && !defined(__clang__)
514 #pragma GCC diagnostic pop
515 #endif
516
517 agxAssert(this->isRigidTransformation());
518 return *this;
519 }
520
521
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 )
527 {
528
529 Matrix4x4T<T>::set(a00, a01, a02, a03, a10, a11, a12, a13, a20, a21, a22, a23, a30, a31, a32, a33);
530 return *this;
531 }
532
533 template <typename T>
535 {
536 this->setRotate(q);
537 this->setTranslate(0.0, 0.0, 0.0);
538
539 return *this;
540 }
541
542
543 template <typename T>
545 {
546 this->setRotate(m3);
547 this->setTranslate(0.0, 0.0, 0.0);
548
549 return *this;
550 }
551
552 template <typename T>
558
559
560 template <typename T>
562 {
563 (*this)(0,0) = (T)m3(0,0);
564 (*this)(0,1) = (T)m3(0,1);
565 (*this)(0,2) = (T)m3(0,2);
566
567 (*this)(1,0) = (T)m3(1,0);
568 (*this)(1,1) = (T)m3(1,1);
569 (*this)(1,2) = (T)m3(1,2);
570
571 (*this)(2,0) = (T)m3(2,0);
572 (*this)(2,1) = (T)m3(2,1);
573 (*this)(2,2) = (T)m3(2,2);
574
575 return *this;
576 }
577
578 template <typename T>
580 {
581 QuatT<T> quat;
582 quat.setRotate(from,to);
583 this->setRotate(quat);
584 return *this;
585 }
586
587 template <typename T>
589 {
590 QuatT<T> quat;
591 quat.setRotate( angle, axis);
592 this->setRotate(quat);
593 return *this;
594 }
595
596 template <typename T>
598 {
599 QuatT<T> quat;
600 quat.setRotate( angle, x, y, z);
601 this->setRotate(quat);
602 return *this;
603 }
604
605 template <typename T>
607 T angle2, const Vec3T<T>& axis2,
608 T angle3, const Vec3T<T>& axis3 )
609 {
610 QuatT<T> quat;
611 quat.setRotate(angle1, axis1,
612 angle2, axis2,
613 angle3, axis3);
614 this->setRotate(quat);
615 return *this;
616 }
617
618 template <typename T>
620 {
621 this->m_data[3][0] = t[0];
622 this->m_data[3][1] = t[1];
623 this->m_data[3][2] = t[2];
624
625 return *this;
626 }
627
628 template <typename T>
630 {
631 this->m_data[3][0] = tx;
632 this->m_data[3][1] = ty;
633 this->m_data[3][2] = tz;
634
635 return *this;
636 }
637
638
639 template <typename T>
641 {
642 this->set(1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1);
643 return *this;
644 }
645
646
647 /*=====================================================
648 Static methods
649 =======================================================*/
650
651 template <typename T>
653 {
654 return AffineMatrix4x4T<T>(
655 0, -vec.z(), vec.y(), 0,
656 vec.z(), 0, -vec.x(), 0,
657 -vec.y(), vec.x(), 0, 0,
658 0, 0, 0, 1);
659 }
660
661
662 template <typename T>
664 {
666 m.setTranslate(dv);
667 return m;
668 }
669
670 template <typename T>
672 {
674 m.setTranslate(x, y, z);
675 return m;
676 }
677
678 template <typename T>
680 {
682 m.setRotate(from, to);
683 return m;
684 }
685
686 template <typename T>
687 inline AffineMatrix4x4T<T> AffineMatrix4x4T<T>::rotate( T angle, T x, T y, T z )
688 {
690 m.setRotate(angle, x, y, z);
691 return m;
692 }
693
694 template <typename T>
696 {
698 m.setRotate(angle, axis);
699 return m;
700 }
701
702 template <typename T>
704 T angle2, const Vec3T<T>& axis2,
705 T angle3, const Vec3T<T>& axis3 )
706 {
708 m.setRotate(angle1, axis1, angle2, axis2, angle3, axis3);
709 return m;
710 }
711
712
713 /*=====================================================
714 Operators
715 =======================================================*/
716 template <typename T>
718 {
719 agx::prefetch<agx::L1>( lhs.m_data );
720 agx::prefetch<agx::L1>( rhs.m_data );
721
722 if (&lhs==this)
723 {
724 postMult(rhs);
725 return;
726 }
727 if (&rhs==this)
728 {
729 preMult(lhs);
730 return;
731 }
732
733 this->m_data[0][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 0);
734 this->m_data[0][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 1);
735 this->m_data[0][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 0, 2);
736
737 this->m_data[1][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 0);
738 this->m_data[1][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 1);
739 this->m_data[1][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 1, 2);
740
741 this->m_data[2][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 0);
742 this->m_data[2][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 1);
743 this->m_data[2][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 2, 2);
744
745 this->m_data[3][0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 0) + rhs.m_data[3][0];
746 this->m_data[3][1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 1) + rhs.m_data[3][1];
747 this->m_data[3][2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3(lhs, rhs, 3, 2) + rhs.m_data[3][2];
748
749 }
750
751 template <typename T>
753 {
754
755 // more efficient method just use a T[4] for temporary storage.
756 T t[4];
757 for(size_t col=0; col<3; ++col) {
758 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 0, col );
759 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 1, col );
760 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 2, col );
761 t[3] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( other, *this, 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];
766 }
767 }
768
769 template <typename T>
771 {
772
773 // more efficient method just use a T[3] for temporary storage.
774 T t[3];
775 for(size_t row=0; row<3; ++row)
776 {
777 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 0 );
778 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 1 );
779 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, row, 2 );
780
781 AGX_AFFINEMATRIX4X4_SET_ROW(row, t[0], t[1], t[2] )
782 }
783 // treat last row differently
784 t[0] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 0 ) + other.m_data[3][0];
785 t[1] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 1 ) + other.m_data[3][1];
786 t[2] = AGX_AFFINEMATRIX4X4_INNER_PRODUCT_3( *this, other, 3, 2 ) + other.m_data[3][2];
787 AGX_AFFINEMATRIX4X4_SET_ROW(3, t[0], t[1], t[2] )
788 }
789
790 template <typename T>
792 {
793 for (unsigned i = 0; i < 3; ++i)
794 {
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];
799 }
800 return *this;
801 }
802
803 template <typename T>
805 {
806 for (unsigned i = 0; i < 3; ++i)
807 {
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];
812 }
813 return *this;
814 }
815
816
817
818 template <typename T>
820 {
821 if ( this != &rhs )
822 this->set( rhs.ptr() );
823
824 return *this;
825 }
826
827
828 template <typename T>
830 {
832 r.mult( *this, m );
833 return r;
834 }
835
836 template <typename T>
838 {
840 r.mult( *this, m );
841 return r;
842 }
843
844
845 template <typename T>
847 {
848 if ( this == &other )
849 {
850 AffineMatrix4x4T<T> temp( other );
851 postMult( temp );
852 }
853 else postMult( other );
854 }
855
856
857 template <typename T>
859 {
860 return postMult(v);
861 }
862
863 template <typename T>
865 {
866 return postMult(v);
867 }
868
869 template <typename T>
871 {
872 return m.preMult(v);
873 }
874 template <typename T>
875
876
878 {
879 return m.preMult(v);
880 }
881
882
883 template <typename T>
885 {
886 T x,y,z;
887
888 // diagonal
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];
892
893 // rotation
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];
900
901 x = rhs.m_data[3][0];
902 y = rhs.m_data[3][1];
903 z = rhs.m_data[3][2];
904
905 // translation
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]);
909
910 return true;
911 }
912
913 template <typename T>
915 {
916 return
917 agx::equivalent(a(0, 0), b(0, 0), epsilon) &&
918 agx::equivalent(a(0, 1), b(0, 1), epsilon) &&
919 agx::equivalent(a(0, 2), b(0, 2), epsilon) &&
920 agx::equivalent(a(0, 3), b(0, 3), epsilon) &&
921 agx::equivalent(a(1, 0), b(1, 0), epsilon) &&
922 agx::equivalent(a(1, 1), b(1, 1), epsilon) &&
923 agx::equivalent(a(1, 2), b(1, 2), epsilon) &&
924 agx::equivalent(a(1, 3), b(1, 3), epsilon) &&
925 agx::equivalent(a(2, 0), b(2, 0), epsilon) &&
926 agx::equivalent(a(2, 1), b(2, 1), epsilon) &&
927 agx::equivalent(a(2, 2), b(2, 2), epsilon) &&
928 agx::equivalent(a(2, 3), b(2, 3), epsilon) &&
929 agx::equivalent(a(3, 0), b(3, 0), epsilon) &&
930 agx::equivalent(a(3, 1), b(3, 1), epsilon) &&
931 agx::equivalent(a(3, 2), b(3, 2), epsilon) &&
932 agx::equivalent(a(3, 3), b(3, 3), epsilon);
933 }
934
935
936 template <>
938 {
939 #if AGX_USE_SSE()
940 multSSE32Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
941 #else
942 mult(lhs, rhs);
943 #endif
944 }
945
946 template <>
948 {
949 #if AGX_USE_SSE()
950 multSSE64Implementation(this->ptr(), lhs.ptr(), rhs.ptr());
951 #else
952 mult(lhs, rhs);
953 #endif
954 }
955
956
957 template <>
959 {
960 return value.inverse();
961 }
962
963
964 template <>
966 {
967 return value.inverse();
968 }
969
970
971 template <typename T>
973 {
974 return Real((*this)(i,j));
975 }
976
977 template <typename T>
978 AGX_FORCE_INLINE void AffineMatrix4x4T<T>::set(Real val, size_t i, size_t j)
979 {
980 (*this)(i,j) = T(val);
981 }
982
983
984 template <typename T>
986 {
987 return point * (*this);
988 }
989
990 template <typename T>
992 {
993 return this->transform3x3(vector);
994 }
995
996
997
998}
999
1000#include <agxData/Type.h>
1001
1002AGX_TYPE_BINDING(agx::AffineMatrix4x4f, "AffineMatrix4x4")
1003AGX_TYPE_BINDING(agx::AffineMatrix4x4d, "AffineMatrix4x4")
1004
1005#ifdef _MSC_VER
1006# pragma warning(pop)
1007#endif
1008
1009#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
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...
Definition EulerAngles.h:70
Matrix class for affine transformations.
Definition Matrix4x4.h:56
void mult(const Matrix4x4T< T > &, const Matrix4x4T< T > &)
Definition Matrix4x4.h:774
Matrix4x4T< T > & setRotate(const QuatT< T > &q)
Matrix4x4T< T > & set(T const *const ptr)
Definition Matrix4x4.h:487
bool isRigidTransformation() const
Definition Matrix4x4.h:457
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.
#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)
double Real
Definition Real.h:42
AffineMatrix4x4T< Real64 > AffineMatrix4x4d
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)