Fix Line3 distance for parallel and non-unit directions - #224
Doribelove wants to merge 1 commit into
Conversation
Project principal-point displacement onto the common normal of unit directions, with a scalar perpendicular-distance fallback for parallel lines. Cover intersecting, coincident and skew lines, direction rescaling, operand reversal and the parallel tolerance. AI assistance: prepared with Codex; validation executed locally.
47f6f2a to
9600087
Compare
|
I rebased this PR onto current |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thank you for your interest in SMTB, and for the nice, well-tested fix! I dug into this a bit further and independently confirmed both bugs it fixes are real: the parallel branch on I've filed #231 to track a related, out-of-scope issue: Approving — thanks again for the contribution! |
|
Thank you for reviewing and approving the fix. I checked the remaining red The repository's CI invokes the reusable Sphinx workflow for pull requests, and that workflow currently publishes unconditionally. A maintainer-side adjustment that builds docs on PRs but publishes only from trusted pushes would keep the documentation check without requiring write access from a fork PR. I updated the PR description with the current CI results; no additional commit was added to the approved patch. Prepared with Codex on behalf of @Doribelove. |
|
I've approved this. CI fails because of an unmerged PR #222, not your code. There's a big backlog of PRs for RAI to merge, including a lot of my own PRs :( |
Line3.distance()raisesNameErrorfor parallel lines and can return incorrect distances for skew or intersecting lines. For example:The old expression divides by the squared cross-product norm and uses a reciprocal product that mixes unit directions with unnormalized moments. Scaling directions can therefore change the result; a translated intersecting pair can also return a nonzero distance.
Compute the displacement between principal points and project it onto the common normal of the unit directions. For parallel directions, use the perpendicular component of that displacement and return a scalar. Apply the existing
tolparameter to the parallel-direction test.Initial validation on base
f6a572c6e75e2a7e3c06e632bc34153941e00404:tests/test_geom3d.py; with the fix: 39 passed.testssuite: baseline 346 passed, 3 skipped; fixed 367 passed, 3 skipped, on Python 3.10/NumPy 2.2.6 and Python 3.12/NumPy 2.5.3. Existing plotting/deprecation warnings remain.numpy.linalg.lstsq, including parallel/intersecting/skew lines, sign/scale changes, rigid transformations and operand reversal.git diff --check, wheel and sdist builds passed.The branch is now rebased onto upstream
2de7801(current head9600087). On this updated tree, the completetestssuite passes with 368 passed, 3 skipped on Python 3.10.12, and the four pre-commit hooks on both changed files andgit diff --checkpass. The newer upstream commit adds a separate spatial-vector regression, accounting for one more passing test than the initial run. GitHub Actions has since run: all 10 platform/Python unittest jobs, the aggregate test check, and Codecov passed. The Sphinx documentation build succeeded with 22 warnings, but its finalgh-pagespush failed with HTTP 403 becausegithub-actions[bot]lacks write permission for this fork PR. This patch changes onlyspatialmath/geom3d.pyandtests/test_geom3d.py.AI assistance: the implementation, tests and this description were prepared with Codex; the local validation commands were executed locally, and the multi-platform results above come from GitHub Actions.