5 #ifndef __pinocchio_autodiff_casadi_math_quaternion_hpp__
6 #define __pinocchio_autodiff_casadi_math_quaternion_hpp__
17 template<
typename _Scalar>
20 typedef ::casadi::Matrix<_Scalar>
Scalar;
21 template<
typename Matrix3,
typename QuaternionDerived>
22 static inline void run(Eigen::QuaternionBase<QuaternionDerived> &
q,
const Matrix3 & mat)
25 typename Eigen::internal::traits<QuaternionDerived>::Coefficients QuatCoefficients;
28 typedef Eigen::Quaternion<Scalar, QuatCoefficientsPlainType::Options> QuaternionPlain;
29 QuaternionPlain quat_t_positive;
34 QuaternionPlain quat_t_negative_0, quat_t_negative_1, quat_t_negative_2;
44 (cond1 &&
mat.coeff(2, 2) >
mat.coeff(1, 1)) || (
mat.coeff(2, 2) >
mat.coeff(0, 0));
46 for (Eigen::DenseIndex k = 0; k < 4; ++k)
48 Scalar t_is_negative_cond1 = Scalar::if_else(
49 cond1, quat_t_negative_1.coeffs().coeff(k), quat_t_negative_0.coeffs().coeff(k));
50 Scalar t_is_negative_cond2 =
51 Scalar::if_else(cond2, quat_t_negative_2.coeffs().coeff(k), t_is_negative_cond1);
53 q.coeffs().coeffRef(k) = Scalar::if_else(
54 t_greater_than_zero, quat_t_positive.coeffs().coeff(k), t_is_negative_cond2);
69 template<
class Scalar,
int Options>
70 struct quaternionbase_assign_impl<
Eigen::Matrix<::casadi::Matrix<Scalar>, 3, 3, Options>, 3, 3>
72 template<
typename QuaternionDerived>
74 QuaternionBase<QuaternionDerived> & q,
75 const Eigen::Matrix<::casadi::Matrix<Scalar>, 3, 3,
Options> & a_mat)
78 ::casadi::Matrix<Scalar>,
false>
::run(
q, a_mat);
84 #endif // ifndef __pinocchio_autodiff_casadi_math_quaternion_hpp__