Repository navigation
Commit 81071a3
authored
Normalize the axis in UnitQuaternion.AngVec (#266)
`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 by
`smb.iszero()` after unit conversion.
Away from that zero-angle tolerance, a zero axis raises `ValueError`.
The base functions (`angvec2r`, `angvec2tr` and `SO3.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:
- Original normalization regressions against unchanged master: 5 failed,
3 passed; original fix: 8 passed.
- Follow-up tests against the previous PR head `54fb3c8`: four near-zero
subtest failures; the four other new control subtests passed.
- Final focused tests: 12 passed, 8 subtests passed.
- Full suite: 414 passed, 11 skipped, 63 subtests passed (15 warnings).
- Project-pinned Black 23.10.0 and whitespace checks passed. All
execution and formatting ran on the remote workstation.
AI assistance: an AI coding agent helped investigate, implement, test,
and review this change. No independent human review is claimed.1 parent 51af998 commit 81071a3
2 files changed
Lines changed: 88 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1544 | 1544 | | |
1545 | 1545 | | |
1546 | 1546 | | |
1547 | | - | |
1548 | | - | |
| 1547 | + | |
| 1548 | + | |
| 1549 | + | |
1549 | 1550 | | |
1550 | 1551 | | |
1551 | 1552 | | |
1552 | 1553 | | |
1553 | 1554 | | |
| 1555 | + | |
| 1556 | + | |
| 1557 | + | |
1554 | 1558 | | |
1555 | 1559 | | |
1556 | 1560 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
0 commit comments