29 #ifndef HECTOR_POSE_ESTIMATION_EIGEN_QUATERNIONBASE_PLUGIN 30 #define HECTOR_POSE_ESTIMATION_EIGEN_QUATERNIONBASE_PLUGIN 32 #ifndef EIGEN_QUATERNIONBASE_PLUGIN 33 #define EIGEN_QUATERNIONBASE_PLUGIN <hector_pose_estimation/Eigen/QuaternionBaseAddons.h> 36 #else // HECTOR_POSE_ESTIMATION_EIGEN_QUATERNIONBASE_PLUGIN 38 template <
typename OtherDerived>
39 Derived &fromRotationVector(
const MatrixBase<OtherDerived> &rotation_vector)
41 eigen_assert(rotation_vector.size() == 3);
43 const double angle = rotation_vector.norm();
44 double sin_angle_2, cos_angle_2;
45 ::sincos(angle / 2., &sin_angle_2, &cos_angle_2);
46 double sin_angle_norm_2 = 0.5;
47 if (angle > NumTraits<double>::dummy_precision()) sin_angle_norm_2 = sin_angle_2 / angle;
50 vec() = rotation_vector * sin_angle_norm_2;
55 Vector3 toRotationVector()
const 57 eigen_assert(squaredNorm() == 1.0);
58 Scalar vector_norm = vec().norm();
59 if (vector_norm <= NumTraits<Scalar>::dummy_precision())
60 return vec() * Scalar(2.);
62 return vec() / vector_norm * ::acos(
w()) * Scalar(2.);
65 #endif // HECTOR_POSE_ESTIMATION_EIGEN_QUATERNIONBASE_PLUGIN TFSIMD_FORCE_INLINE tfScalar angle(const Quaternion &q1, const Quaternion &q2)
TFSIMD_FORCE_INLINE Vector3()
TFSIMD_FORCE_INLINE const tfScalar & w() const