11#ifndef EIGEN_EULERANGLES_H
12#define EIGEN_EULERANGLES_H
14#include "./InternalHeaderCheck.h"
41template<
typename Derived>
42EIGEN_DEVICE_FUNC
inline Matrix<typename MatrixBase<Derived>::Scalar,3,1>
46 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
50 const Index odd = ((a0 + 1) % 3 == a1) ? 0 : 1;
52 const Index j = (a0 + 1 + odd) % 3;
53 const Index k = (a0 + 2 - odd) % 3;
65 Scalar s2 = numext::hypot(coeff(j, i), coeff(k, i));
68 res[0] = numext::atan2(coeff(j, i), coeff(k, i));
70 res[1] = numext::atan2(s2, coeff(i, i));
82 res[0] = numext::atan2(-coeff(j, i), -coeff(k, i));
83 res[1] = -numext::atan2(s2, coeff(i, i));
96 Scalar s1 = numext::sin(res[0]);
97 Scalar c1 = numext::cos(res[0]);
98 res[2] = numext::atan2(c1 * coeff(j, k) - s1 * coeff(k, k), c1 * coeff(j, j) - s1 * coeff(k, j));
109 res[0] = numext::atan2(coeff(j, k), coeff(k, k));
111 Scalar c2 = numext::hypot(coeff(i, i), coeff(i, j));
113 res[1] = numext::atan2(-coeff(i, k), c2);
115 Scalar s1 = numext::sin(res[0]);
116 Scalar c1 = numext::cos(res[0]);
117 res[2] = numext::atan2(s1 * coeff(k, i) - c1 * coeff(j, i), c1 * coeff(j, j) - s1 * coeff(k, j));
137template<
typename Derived>
142 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Derived, 3, 3)
146 const Index odd = ((a0 + 1) % 3 == a1) ? 0 : 1;
148 const Index j = (a0 + 1 + odd) % 3;
149 const Index k = (a0 + 2 - odd) % 3;
153 res[0] = numext::atan2(coeff(j, i), coeff(k, i));
154 if ((odd && res[0] <
Scalar(0)) || ((!odd) && res[0] >
Scalar(0)))
158 res[0] -=
Scalar(EIGEN_PI);
162 res[0] +=
Scalar(EIGEN_PI);
165 Scalar s2 = numext::hypot(coeff(j, i), coeff(k, i));
166 res[1] = -numext::atan2(s2, coeff(i, i));
170 Scalar s2 = numext::hypot(coeff(j, i), coeff(k, i));
171 res[1] = numext::atan2(s2, coeff(i, i));
184 Scalar s1 = numext::sin(res[0]);
185 Scalar c1 = numext::cos(res[0]);
186 res[2] = numext::atan2(c1 * coeff(j, k) - s1 * coeff(k, k), c1 * coeff(j, j) - s1 * coeff(k, j));
190 res[0] = numext::atan2(coeff(j, k), coeff(k, k));
191 Scalar c2 = numext::hypot(coeff(i, i), coeff(i, j));
192 if ((odd && res[0] <
Scalar(0)) || ((!odd) && res[0] >
Scalar(0)))
196 res[0] -=
Scalar(EIGEN_PI);
200 res[0] +=
Scalar(EIGEN_PI);
202 res[1] = numext::atan2(-coeff(i, k), -c2);
206 res[1] = numext::atan2(-coeff(i, k), c2);
208 Scalar s1 = numext::sin(res[0]);
209 Scalar c1 = numext::cos(res[0]);
210 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:61
Base class for all dense matrices, vectors, and expressions.
Definition MatrixBase.h:52
The matrix class, also used for vectors and row-vectors.
Definition Matrix.h:182
Namespace containing all symbols from the Eigen library.
Definition Core:139
EIGEN_DEFAULT_DENSE_INDEX_TYPE Index
The Index type as used for the API.
Definition Meta.h:82