Repository navigation
Commit 9ac32e7
committed
fix: SO3.RotatedVector returned identity for antipodal vectors
SO3.RotatedVector(v1, v2) computes the rotation axis as v1 x v2. That
cross product is zero whenever v1 and v2 are (anti)parallel, and the
existing singularity check treated both cases identically -- returning
identity regardless. Correct only when v1 and v2 point the same way;
when they're antipodal (v2 == -v1), the correct answer is a 180 degree
rotation about any axis perpendicular to v1, not identity.
Distinguish the two cases via the sign of v1.v2 at the singularity.
The antipodal case uses the closed form for a 180 degree rotation
about a unit axis u (R = 2*u*u^T - I), with u found by crossing v1
against whichever world axis it's least aligned with.
Found while building spatialgeometry's Arrow.FromTo(start, end), which
needs exactly this "rotate a reference axis to point along an
arbitrary direction" operation and hit the bug immediately for an
arrow pointing straight backward relative to its own rest orientation.1 parent 8b83c1f commit 9ac32e7
2 files changed
Lines changed: 31 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
769 | 769 | | |
770 | 770 | | |
771 | 771 | | |
772 | | - | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
773 | 790 | | |
774 | 791 | | |
775 | 792 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
726 | 726 | | |
727 | 727 | | |
728 | 728 | | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
729 | 742 | | |
730 | 743 | | |
731 | 744 | | |
| |||
0 commit comments