5 #ifndef __pinocchio_autodiff_cppad_math_quaternion_hpp__
6 #define __pinocchio_autodiff_cppad_math_quaternion_hpp__
17 template<
typename _Scalar>
22 template<
typename Matrix3,
typename QuaternionDerived>
23 static inline void run(Eigen::QuaternionBase<QuaternionDerived> &
q,
const Matrix3 & mat)
26 typename Eigen::internal::traits<QuaternionDerived>::Coefficients QuatCoefficients;
29 typedef Eigen::Quaternion<ADScalar, QuatCoefficientsPlainType::Options> QuaternionPlain;
30 QuaternionPlain quat_t_positive;
35 QuaternionPlain quat_t_negative_0, quat_t_negative_1, quat_t_negative_2;
42 for (Eigen::DenseIndex k = 0; k < 4; ++k)
44 ADScalar t_is_negative_cond1 = CppAD::CondExpGt<Scalar>(
45 mat.coeff(1, 1),
mat.coeff(0, 0), quat_t_negative_1.coeffs().coeff(k),
46 quat_t_negative_0.coeffs().coeff(k));
48 ADScalar t_is_negative_cond2 = CppAD::CondExpGt<Scalar>(
49 mat.coeff(2, 2),
mat.coeff(0, 0), quat_t_negative_2.coeffs().coeff(k),
50 CppAD::CondExpGt<Scalar>(
51 mat.coeff(1, 1),
mat.coeff(0, 0),
52 CppAD::CondExpGt<Scalar>(
53 mat.coeff(2, 2),
mat.coeff(1, 1), quat_t_negative_2.coeffs().coeff(k),
55 t_is_negative_cond1));
56 q.coeffs().coeffRef(k) = CppAD::CondExpGt<Scalar>(
57 t,
ADScalar(0), quat_t_positive.coeffs().coeff(k), t_is_negative_cond2);
68 #endif // ifndef __pinocchio_autodiff_casadi_math_quaternion_hpp__