Preserve small rotations in quaternion-to-axis-angle conversion - #564
Open
sylvesterkaczmarek wants to merge 1 commit into
Open
sylvesterkaczmarek wants to merge 1 commit into
sylvesterkaczmarek wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #563.
Compute the principal angle with atan2 using the quaternion's vector magnitude. Arccos of the scalar loses valid small rotations once that scalar rounds to one, returning zero even above the existing tolerance.
Retain the principal-angle range, negative-pi half-turn convention, subthreshold zero output and scalar-range validation. Input arrays are not modified.
Validation
Twenty-seven regression cases cover small and ordinary angles, equivalent quaternion signs, identity/subthreshold cases, half turns and invalid scalar controls. Expected rotations are checked analytically and against MuJoCo's actual mju_axisAngle2Quat/mju_quat2Vel functions, with rotation-matrix roundtrips.
dm_control/utilsanddm_control/composer/variation: 162 passed on Python 3.11.16 and 3.12.11, with MuJoCo 3.14.0.git diff --checkpassed.Validation was local on macOS. One existing zero-axis-angle RuntimeWarning remains unchanged. Tests use native conversion routines, not rendering or the complete control-suite simulation matrix. Nonunit quaternion semantics and rotations below the existing tolerance are outside the intended change.
Based on main at
a04e3e4cf56c12117d2294bb090f9acec21e5c67. No dependencies or workflows change.