Skip to content
Snippets Groups Projects
Commit 85c91b01 authored by Joseph Mirabel's avatar Joseph Mirabel Committed by Joseph Mirabel
Browse files

[Minor][C++] Update firstOrderNormalize

parent 570413c5
No related branches found
No related tags found
No related merge requests found
......@@ -68,13 +68,17 @@ namespace se3
/// division are used (except a division by 2).
///
/// \warning \f$ ||q||^2 - 1 \f$ should already be close to zero.
///
/// \note See
/// http://eigen.tuxfamily.org/dox/TopicFunctionTakingEigenTypes.html#title3
/// to know the reason why the argument is const.
template <typename D> void
firstOrderNormalize(const Eigen::QuaternionBase<D> & q)
{
assert(std::fabs(q.norm() - 1) < 1e-2);
typedef typename D::Scalar Scalar;
const Scalar alpha = ((Scalar)3 - q.squaredNorm()) / 2;
const_cast <Eigen::QuaternionBase<D> &> (q).coeffs() = alpha * q.derived().coeffs();
const_cast <Eigen::QuaternionBase<D> &> (q).coeffs() *= alpha;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment