MCPcopy Create free account
hub / github.com/PX4/eigen / transformations

Function transformations

test/geo_transformations.cpp:86–499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

84}
85
86template<typename Scalar, int Mode, int Options> void transformations()
87{
88 /* this test covers the following files:
89 Cross.h Quaternion.h, Transform.cpp
90 */
91 using std::cos;
92 using std::abs;
93 typedef Matrix<Scalar,3,3> Matrix3;
94 typedef Matrix<Scalar,4,4> Matrix4;
95 typedef Matrix<Scalar,2,1> Vector2;
96 typedef Matrix<Scalar,3,1> Vector3;
97 typedef Matrix<Scalar,4,1> Vector4;
98 typedef Quaternion<Scalar> Quaternionx;
99 typedef AngleAxis<Scalar> AngleAxisx;
100 typedef Transform<Scalar,2,Mode,Options> Transform2;
101 typedef Transform<Scalar,3,Mode,Options> Transform3;
102 typedef typename Transform3::MatrixType MatrixType;
103 typedef DiagonalMatrix<Scalar,3> AlignedScaling3;
104 typedef Translation<Scalar,2> Translation2;
105 typedef Translation<Scalar,3> Translation3;
106
107 Vector3 v0 = Vector3::Random(),
108 v1 = Vector3::Random();
109 Matrix3 matrot1, m;
110
111 Scalar a = internal::random<Scalar>(-Scalar(EIGEN_PI), Scalar(EIGEN_PI));
112 Scalar s0 = internal::random<Scalar>(), s1 = internal::random<Scalar>();
113
114 while(v0.norm() < test_precision<Scalar>()) v0 = Vector3::Random();
115 while(v1.norm() < test_precision<Scalar>()) v1 = Vector3::Random();
116
117 VERIFY_IS_APPROX(v0, AngleAxisx(a, v0.normalized()) * v0);
118 VERIFY_IS_APPROX(-v0, AngleAxisx(Scalar(EIGEN_PI), v0.unitOrthogonal()) * v0);
119 if(abs(cos(a)) > test_precision<Scalar>())
120 {
121 VERIFY_IS_APPROX(cos(a)*v0.squaredNorm(), v0.dot(AngleAxisx(a, v0.unitOrthogonal()) * v0));
122 }
123 m = AngleAxisx(a, v0.normalized()).toRotationMatrix().adjoint();
124 VERIFY_IS_APPROX(Matrix3::Identity(), m * AngleAxisx(a, v0.normalized()));
125 VERIFY_IS_APPROX(Matrix3::Identity(), AngleAxisx(a, v0.normalized()) * m);
126
127 Quaternionx q1, q2;
128 q1 = AngleAxisx(a, v0.normalized());
129 q2 = AngleAxisx(a, v1.normalized());
130
131 // rotation matrix conversion
132 matrot1 = AngleAxisx(Scalar(0.1), Vector3::UnitX())
133 * AngleAxisx(Scalar(0.2), Vector3::UnitY())
134 * AngleAxisx(Scalar(0.3), Vector3::UnitZ());
135 VERIFY_IS_APPROX(matrot1 * v1,
136 AngleAxisx(Scalar(0.1), Vector3(1,0,0)).toRotationMatrix()
137 * (AngleAxisx(Scalar(0.2), Vector3(0,1,0)).toRotationMatrix()
138 * (AngleAxisx(Scalar(0.3), Vector3(0,0,1)).toRotationMatrix() * v1)));
139
140 // angle-axis conversion
141 AngleAxisx aa = AngleAxisx(q1);
142 VERIFY_IS_APPROX(q1 * v1, Quaternionx(aa) * v1);
143

Callers

nothing calls this directly

Calls 15

dont_over_optimizeFunction · 0.85
ScalingFunction · 0.85
angleToVecFunction · 0.85
unitOrthogonalMethod · 0.80
axisMethod · 0.80
linearMethod · 0.80
isIdentityMethod · 0.80
asDiagonalMethod · 0.80
jacobiSvdMethod · 0.80
smallestPositiveAngleMethod · 0.80

Tested by

no test coverage detected