Fix Line3 distance for parallel and non-unit directions - #224
Open
Doribelove wants to merge 1 commit into
Open
Doribelove wants to merge 1 commit into
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.
Doribelove
requested review from
jbarry-bdai,
petercorke and
taughz
as code owners
September 16, 2026 08:09
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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.AI assistance: the implementation, tests and this description were prepared with Codex; the validation commands were executed locally. No full multi-platform CI result is claimed.