11#ifndef EIGEN_EULERANGLES_H
12#define EIGEN_EULERANGLES_H
15#include "./InternalHeaderCheck.h"
44template <
typename Derived>
48 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
52 const Index odd = ((a0 + 1) % 3 == a1) ? 0 : 1;
54 const Index j = (a0 + 1 + odd) % 3;
55 const Index k = (a0 + 2 - odd) % 3;
68 res[0] = numext::atan2(
coeff(j, i),
coeff(k, i));
70 res[1] = numext::atan2(s2,
coeff(i, i));
80 res[0] = numext::atan2(-
coeff(j, i), -
coeff(k, i));
81 res[1] = -numext::atan2(s2,
coeff(i, i));
94 Scalar s1 = numext::sin(res[0]);
95 Scalar c1 = numext::cos(res[0]);
96 res[2] = numext::atan2(c1 *
coeff(j, k) - s1 *
coeff(k, k), c1 *
coeff(j, j) - s1 *
coeff(k, j));
105 res[0] = numext::atan2(
coeff(j, k),
coeff(k, k));
110 res[1] = numext::atan2(-
coeff(i, k), c2);
112 Scalar s1 = numext::sin(res[0]);
113 Scalar c1 = numext::cos(res[0]);
114 res[2] = numext::atan2(s1 *
coeff(k, i) - c1 *
coeff(j, i), c1 *
coeff(j, j) - s1 *
coeff(k, j));
135template <
typename Derived>
139 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
143 const Index odd = ((a0 + 1) % 3 == a1) ? 0 : 1;
145 const Index j = (a0 + 1 + odd) % 3;
146 const Index k = (a0 + 2 - odd) % 3;
149 res[0] = numext::atan2(
coeff(j, i),
coeff(k, i));
150 if ((odd && res[0] <
Scalar(0)) || ((!odd) && res[0] >
Scalar(0))) {
152 res[0] -=
Scalar(EIGEN_PI);
154 res[0] +=
Scalar(EIGEN_PI);
158 res[1] = -numext::atan2(s2,
coeff(i, i));
161 res[1] = numext::atan2(s2,
coeff(i, i));
174 Scalar s1 = numext::sin(res[0]);
175 Scalar c1 = numext::cos(res[0]);
176 res[2] = numext::atan2(c1 *
coeff(j, k) - s1 *
coeff(k, k), c1 *
coeff(j, j) - s1 *
coeff(k, j));
178 res[0] = numext::atan2(
coeff(j, k),
coeff(k, k));
180 if ((odd && res[0] <
Scalar(0)) || ((!odd) && res[0] >
Scalar(0))) {
182 res[0] -=
Scalar(EIGEN_PI);
184 res[0] +=
Scalar(EIGEN_PI);
186 res[1] = numext::atan2(-
coeff(i, k), -c2);
188 res[1] = numext::atan2(-
coeff(i, k), c2);
190 Scalar s1 = numext::sin(res[0]);
191 Scalar c1 = numext::cos(res[0]);
192 res[2] = numext::atan2(s1 *
coeff(k, i) - c1 *
coeff(j, i), c1 *
coeff(j, j) - s1 *
coeff(k, j));
internal::traits< Derived >::Scalar Scalar
Definition DenseBase.h:62
constexpr CoeffReturnType coeff(Index row, Index col) const
Definition DenseCoeffsBase.h:98
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:186
Matrix< Scalar, 3, 1 > eulerAngles(Index a0, Index a1, Index a2) const
Definition EulerAngles.h:136
Matrix< Scalar, 3, 1 > canonicalEulerAngles(Index a0, Index a1, Index a2) const
Definition EulerAngles.h:45
Namespace containing all symbols from the Eigen library.
Definition B01_Experimental.dox:1
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82