Repository navigation
Normalize the axis in UnitQuaternion.AngVec - #266
wpyaoxueros wants to merge 2 commits into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thanks very much for the report and the fix, @wpyaoxueros. I've confirmed the bug: on master Two small things, neither blocking:
|
|
Thanks for confirming the bug and for both suggestions. I've updated The four near-zero subtests fail on the previous PR head and pass with the update. Remote validation: focused tests 12 passed plus 8 subtests; full suite 414 passed, 11 skipped plus 63 subtests. Black 23.10.0 and whitespace checks pass. You're also right about the description: the base angle-axis functions currently return the identity for a zero axis, including at a nonzero angle. I've corrected the PR text and left those functions unchanged for your separate alignment work. |
UnitQuaternion.AngVec(0.5, [1, 2, 3])currently produces a quaternion with norm greater than one and a matrix that is not the requested rotation. Normalize the axis before constructing a nonzero-angle quaternion, while returning the identity for angles considered zero bysmb.iszero()after unit conversion.Away from that zero-angle tolerance, a zero axis raises
ValueError. The base functions (angvec2r,angvec2trandSO3.AngleAxis) currently return the identity for a zero axis, even for a nonzero angle; this PR does not change them. The earlier description incorrectly claimed consistency with those base constructors. Their alignment is separate, as discussed in review.Regression coverage includes norm, angle/axis round-trip, matrix agreement, degrees, unit-axis controls, exact and near-zero angles in both units, and positive/negative small angles outside the tolerance. These controls preserve nonzero rotation with a valid axis and reject a zero axis outside the tolerance.
Validation on the designated Linux workstation, Python 3.11:
54fb3c8: four near-zero subtest failures; the four other new control subtests passed.AI assistance: an AI coding agent helped investigate, implement, test, and review this change. No independent human review is claimed.