10 #ifndef EIGEN_EULERANGLES_H 11 #define EIGEN_EULERANGLES_H 35 template<
typename Derived>
36 EIGEN_DEVICE_FUNC
inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>
39 EIGEN_USING_STD_MATH(atan2)
40 EIGEN_USING_STD_MATH(sin)
41 EIGEN_USING_STD_MATH(cos)
43 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived,3,3)
48 const Index odd = ((a0+1)%3 == a1) ? 0 : 1;
50 const Index j = (a0 + 1 + odd)%3;
51 const Index k = (a0 + 2 - odd)%3;
55 res[0] = atan2(coeff(j,i), coeff(k,i));
56 if((odd && res[0]<
Scalar(0)) || ((!odd) && res[0]>
Scalar(0)))
59 res[0] -=
Scalar(EIGEN_PI);
62 res[0] +=
Scalar(EIGEN_PI);
64 Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
65 res[1] = -atan2(s2, coeff(i,i));
69 Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
70 res[1] = atan2(s2, coeff(i,i));
85 res[2] = atan2(c1*coeff(j,k)-s1*coeff(k,k), c1*coeff(j,j) - s1 * coeff(k,j));
89 res[0] = atan2(coeff(j,k), coeff(k,k));
90 Scalar c2 = Vector2(coeff(i,i), coeff(i,j)).norm();
91 if((odd && res[0]<
Scalar(0)) || ((!odd) && res[0]>
Scalar(0))) {
93 res[0] -=
Scalar(EIGEN_PI);
96 res[0] +=
Scalar(EIGEN_PI);
98 res[1] = atan2(-coeff(i,k), -c2);
101 res[1] = atan2(-coeff(i,k), c2);
104 res[2] = atan2(s1*coeff(k,i)-c1*coeff(j,i), c1*coeff(j,j) - s1 * coeff(k,j));
114 #endif // EIGEN_EULERANGLES_H internal::traits< Derived >::Scalar Scalar
The numeric type of the expression' coefficients, e.g.
Definition: DenseBase.h:66
Namespace containing all symbols from the Eigen library.
Definition: bench_norm.cpp:85
EIGEN_DEVICE_FUNC Matrix< Scalar, 3, 1 > eulerAngles(Index a0, Index a1, Index a2) const
Definition: EulerAngles.h:37
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition: Meta.h:33