10 #ifndef EIGEN_EULERANGLES_H
11 #define EIGEN_EULERANGLES_H
35 template<
typename Derived>
36 inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>
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)))
58 res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI);
59 Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
60 res[1] = -atan2(s2, coeff(i,i));
64 Scalar s2 = Vector2(coeff(j,i), coeff(k,i)).norm();
65 res[1] = atan2(s2, coeff(i,i));
78 Scalar s1 = sin(res[0]);
79 Scalar c1 = cos(res[0]);
80 res[2] = atan2(c1*coeff(j,k)-s1*coeff(k,k), c1*coeff(j,j) - s1 * coeff(k,j));
84 res[0] = atan2(coeff(j,k), coeff(k,k));
85 Scalar c2 = Vector2(coeff(i,i), coeff(i,j)).norm();
86 if((odd && res[0]<Scalar(0)) || ((!odd) && res[0]>Scalar(0))) {
87 res[0] = (res[0] > Scalar(0)) ? res[0] - Scalar(M_PI) : res[0] + Scalar(M_PI);
88 res[1] = atan2(-coeff(i,k), -c2);
91 res[1] = atan2(-coeff(i,k), c2);
92 Scalar s1 = sin(res[0]);
93 Scalar c1 = cos(res[0]);
94 res[2] = atan2(s1*coeff(k,i)-c1*coeff(j,i), c1*coeff(j,j) - s1 * coeff(k,j));
104 #endif // EIGEN_EULERANGLES_H
Matrix< Scalar, 3, 1 > eulerAngles(Index a0, Index a1, Index a2) const
Definition: EulerAngles.h:37
internal::traits< Derived >::Index Index
The type of indices.
Definition: DenseBase.h:60