autodiff/cppad/math/quaternion.hpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 2019-2020 INRIA CNRS
3 //
4 
5 #ifndef __pinocchio_autodiff_cppad_math_quaternion_hpp__
6 #define __pinocchio_autodiff_cppad_math_quaternion_hpp__
7 
9 
10 namespace pinocchio
11 {
12  namespace quaternion
13  {
14  namespace internal
15  {
16 
17  template<typename _Scalar>
18  struct quaternionbase_assign_impl<CppAD::AD<_Scalar>, false>
19  {
20  typedef _Scalar Scalar;
21  typedef CppAD::AD<Scalar> ADScalar;
22  template<typename Matrix3, typename QuaternionDerived>
23  static inline void run(Eigen::QuaternionBase<QuaternionDerived> & q, const Matrix3 & mat)
24  {
25  typedef
26  typename Eigen::internal::traits<QuaternionDerived>::Coefficients QuatCoefficients;
27 
28  typedef typename PINOCCHIO_EIGEN_PLAIN_TYPE(QuatCoefficients) QuatCoefficientsPlainType;
29  typedef Eigen::Quaternion<ADScalar, QuatCoefficientsPlainType::Options> QuaternionPlain;
30  QuaternionPlain quat_t_positive;
31 
32  ADScalar t = mat.trace();
34 
35  QuaternionPlain quat_t_negative_0, quat_t_negative_1, quat_t_negative_2;
36 
40 
41  // Build the expression graph
42  for (Eigen::DenseIndex k = 0; k < 4; ++k)
43  {
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));
47 
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),
54  t_is_negative_cond1),
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);
58  }
59  }
60  };
61 
62  } // namespace internal
63 
64  } // namespace quaternion
65 
66 } // namespace pinocchio
67 
68 #endif // ifndef __pinocchio_autodiff_casadi_math_quaternion_hpp__
quaternion.hpp
pinocchio::quaternion::internal::quaternionbase_assign_impl_if_t_negative::run
static void run(Scalar t, Eigen::QuaternionBase< QuaternionDerived > &q, const Matrix3 &mat)
Definition: math/quaternion.hpp:149
pinocchio::quaternion::internal::quaternionbase_assign_impl
Definition: math/quaternion.hpp:142
pinocchio::quaternion::internal::quaternionbase_assign_impl< CppAD::AD< _Scalar >, false >::ADScalar
CppAD::AD< Scalar > ADScalar
Definition: autodiff/cppad/math/quaternion.hpp:21
pinocchio::quaternion::internal::quaternionbase_assign_impl< CppAD::AD< _Scalar >, false >::run
static void run(Eigen::QuaternionBase< QuaternionDerived > &q, const Matrix3 &mat)
Definition: autodiff/cppad/math/quaternion.hpp:23
CppAD
Definition: autodiff/cppad.hpp:146
pinocchio::quaternion::internal::quaternionbase_assign_impl_if_t_positive::run
static void run(Scalar t, Eigen::QuaternionBase< QuaternionDerived > &q, const Matrix3 &mat)
Definition: math/quaternion.hpp:169
mat
mat
pinocchio::q
JointCollectionTpl const Eigen::MatrixBase< ConfigVectorType > & q
Definition: joint-configuration.hpp:1083
t
Transform3f t
pinocchio::PINOCCHIO_EIGEN_PLAIN_TYPE
PINOCCHIO_EIGEN_PLAIN_TYPE(ConfigVectorType) integrate(const ModelTpl< Scalar
Integrate a configuration vector for the specified model for a tangent vector during one unit time.
pinocchio::quaternion::internal::quaternionbase_assign_impl< CppAD::AD< _Scalar >, false >::Scalar
_Scalar Scalar
Definition: autodiff/cppad/math/quaternion.hpp:20
pinocchio
Main pinocchio namespace.
Definition: timings.cpp:27


pinocchio
Author(s):
autogenerated on Fri Nov 1 2024 02:41:48