Repository navigation
Commit a016ffb
authored
Make vector projections independent of direction scale (#242)
`project(v1, v2)` currently multiplies by `dot(v1, v2)` without dividing
by `dot(v2, v2)`. As a result, projecting `[3,1,4]` onto `[2,2,0]`
returns `[16,16,0]` instead of `[2,2,0]`; `orthogonalize()` then
produces a vector that is not perpendicular to its reference direction.
List/tuple direction inputs also raise TypeError.
Convert the documented array-like arguments to vectors and compute the
full projection formula. Rescale the direction before dot products so
very small/large directions do not underflow/overflow. Keep the
historical zero-direction result.
Validation: two regressions fail before the fix; the zero-direction
control passes. Tests cover signed/scaled directions, list/tuple inputs,
scales1e-200 and1e200, and normalized/unnormalized perpendicular
results. All184 base+pose3d tests pass with1 skip and8 existing
warnings; repository-pinned Black23.10.0 and `git diff --check` pass.
Prepared with AI assistance.1 parent 6ed7eff commit a016ffb
2 files changed
Lines changed: 25 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
829 | 829 | | |
830 | 830 | | |
831 | 831 | | |
832 | | - | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
833 | 840 | | |
834 | 841 | | |
835 | 842 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
36 | 53 | | |
37 | 54 | | |
38 | 55 | | |
| |||
0 commit comments