12 template <
typename Derived>
14 const Eigen::MatrixBase<Derived>& R) {
17 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Eigen::MatrixBase<Derived>, 3, 3);
19 typename Derived::Scalar theta = acos((R.trace() - 1.0) / 2.0);
21 if (theta > std::numeric_limits<typename Derived::Scalar>::epsilon()) {
22 a << R(2, 1) - R(1, 2), R(0, 2) - R(2, 0), R(1, 0) - R(0, 1), theta;
23 a.head<3>() *= 1.0 / (2.0 *
sin(theta));
25 a << 1.0, 0.0, 0.0, 0.0;
30 template <
typename Derived>
32 const Eigen::MatrixBase<Derived>& M) {
33 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Eigen::MatrixBase<Derived>, 3, 3);
35 typedef typename Derived::Scalar Scalar;
36 Eigen::Matrix<Scalar, 4, 3>
A;
37 A.row(0) << 1.0, 1.0, 1.0;
38 A.row(1) << 1.0, -1.0, -1.0;
39 A.row(2) << -1.0, 1.0, -1.0;
40 A.row(3) << -1.0, -1.0, 1.0;
42 Eigen::Index ind, max_col;
43 Scalar val = B.maxCoeff(&ind, &max_col);
49 w =
sqrt(1.0 + val) / 2.0;
51 x = (M(2, 1) - M(1, 2)) / w4;
52 y = (M(0, 2) - M(2, 0)) / w4;
53 z = (M(1, 0) - M(0, 1)) / w4;
58 Scalar s = 2.0 *
sqrt(1.0 + val);
59 w = (M(2, 1) - M(1, 2)) / s;
61 y = (M(0, 1) + M(1, 0)) / s;
62 z = (M(0, 2) + M(2, 0)) / s;
67 Scalar s = 2.0 * (
sqrt(1.0 + val));
68 w = (M(0, 2) - M(2, 0)) / s;
69 x = (M(0, 1) + M(1, 0)) / s;
71 z = (M(1, 2) + M(2, 1)) / s;
76 Scalar s = 2.0 * (
sqrt(1.0 + val));
77 w = (M(1, 0) - M(0, 1)) / s;
78 x = (M(0, 2) + M(2, 0)) / s;
79 y = (M(1, 2) + M(2, 1)) / s;
90 template <
typename Derived>
92 const Eigen::MatrixBase<Derived>& R) {
96 EIGEN_STATIC_ASSERT_MATRIX_SPECIFIC_SIZE(Eigen::MatrixBase<Derived>, 3, 3);
99 rpy << atan2(R(2, 1), R(2, 2)),
100 atan2(-R(2, 0),
sqrt(pow(R(2, 1), 2.0) + pow(R(2, 2), 2.0))),
101 atan2(R(1, 0), R(0, 0));
105 template <
typename Derived>
107 const Eigen::MatrixBase<Derived>& R,
int rotation_type) {
108 typedef typename Derived::Scalar Scalar;
109 switch (rotation_type) {
111 return Eigen::Matrix<Scalar, Eigen::Dynamic, 1>(0, 1);
117 throw std::runtime_error(
"rotation representation type not recognized");
std::vector< Number > x
Definition: IpoptSolver.cpp:169
This file contains abbreviated definitions for certain specializations of Eigen::Matrix that are comm...
Eigen::Matrix< Scalar, 4, 1 > Vector4
A column vector of size 4, templated on scalar type.
Definition: eigen_types.h:28
Definition: constants.h:3
VectorX< typename Derived::Scalar > rotmat2Representation(const Eigen::MatrixBase< Derived > &R, int rotation_type)
Definition: rotation_matrix.h:106
Vector4< typename Derived::Scalar > rotmat2quat(const Eigen::MatrixBase< Derived > &M)
Definition: rotation_matrix.h:31
Eigen::Matrix< Scalar, Eigen::Dynamic, 1 > VectorX
A column vector of any size, templated on scalar type.
Definition: eigen_types.h:36
FunctionalForm sqrt(FunctionalForm const &x)
Definition: functional_form.cc:208
Vector4< typename Derived::Scalar > rotmat2axis(const Eigen::MatrixBase< Derived > &R)
Definition: rotation_matrix.h:13
Eigen::Matrix< Scalar, 3, 1 > Vector3
A column vector of size 3, templated on scalar type.
Definition: eigen_types.h:24
Vector3< typename Derived::Scalar > rotmat2rpy(const Eigen::MatrixBase< Derived > &R)
Definition: rotation_matrix.h:91
FunctionalForm sin(FunctionalForm const &x)
Definition: functional_form.cc:203