AngleAxis from QuaternionBase , better precision
Submitted by Michael Norel
Assigned to Nobody
Link to original bugzilla bug (#1312)
Version: 3.2
Description
- 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.
-
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].
-
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.