Geometry/EulerAngles: introduce canonicalEulerAngles
This MR is a continuation of reverted !1301 (merged). The MR implements same correction of the returned solutions from Eigen's non-standard angle ranges to standard canonical ranges in the form of a new canonicalEulerAngles
method of MatrixBase
, instead of modifying behaviour of eulerAngles
, which is now marked as deprecated.
The implementation has been factored out to a protected method MatrixBase::eulerAnglesImpl
, which is utilized both by the deprecated eulerAngles
, and by the new canonicalEulerAngles
which makes sure that the solution is in the respective canonical Tait-Bryan/proper Euler angle ranges.
canonicalEulerAngles
has been implemented by taking and tweaking the code for eulerAngles
, and using the same battle-tested expressions for calculating angles. The code for tweaking the first angle to be in Eigen's non-standard [0, pi] range has been removed. We instead take care when passing arguments to atan2
to ensure that the results are in correct quadrants for the solution to be canonical. The level of documentation has also been significantly increased. The method of indexing archetype matrices from Graphics Gems IV should be apparent from the comments, and the used formulas should should be easier to understand and verify.