AngleAxis from QuaternionBase , better precision

Submitted by Michael Norel

Assigned to Nobody

Link to original bugzilla bug (#1312)
Version: 3.2

Description

  1. m_angle = Scalar(2)*acos((min)((max)(Scalar(-1),q.w()),Scalar(1)));

Angle can be computed with better precision using atan2(sqrt(n2), q.w()), without check for "1" overflow.

  1. Also, for better precision , it is good to switch sign of input quaternion to have positive q.w(), it keeps rotation angle in [0, PI].

  2. The check "if (n2 < NumTraits<Scalar>::dummy_precision()*NumTraits<Scalar>::dummy_precision())"
    can be changed to strong comparison with "zero", and provide same relative precision for small rotations without side effects.

Blocking

#1244

Edited by Eigen Bugzilla