feat(g.Line): add isCollinear() and use it in the jumpover connector - #3503
Open
kumilingus wants to merge 3 commits into
Open
feat(g.Line): add isCollinear() and use it in the jumpover connector#3503kumilingus wants to merge 3 commits into
kumilingus wants to merge 3 commits into
Conversation
`isCollinear(line)` is true when all four endpoints lie on one infinite line. It uses the same exact cross-product test as `containsPoint()` and is checked in both directions so a zero-length line does not pass trivially. The jumpover connector's private `overlapExists()` was a bounding-box test (true for crossing lines too) and `sortPointsAscending()` could undo its own x-sort for non-axis-aligned lines. Both are replaced by `thisLine.isCollinear(line) && thisLine.containsPoint(line.end)`, which is what the stacked-links fix (clientIO#2255) actually needs. A perpendicular segment that merely ends on the link no longer causes the following segment to be skipped. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
g.Line#isCollinear(line)—truewhen all four endpoints lie on one infinite line. Same exactcross() === 0test ascontainsPoint()/equals(); evaluated in both directions so a zero-length line does not pass trivially (a point off the line →false, two points →true).Jumpover connector — replaces the private helpers added in fix(connectors.Jumpover): stacked links causing jumps #2255:
overlapExists()was a bounding-box overlap test, so crossing/perpendicular lines counted as "overlapping" too.sortPointsAscending()could undo its own x-sort for non-axis-aligned lines (e.g.(10,5)-(0,20)).The call site becomes
thisLine.isCollinear(line) && thisLine.containsPoint(line.end)— collinear + ends on the link is exactly the stacked-links condition. Behaviour change: a perpendicular segment that merely ends on the link (T-junction) no longer causes the following segment to be skipped; that skip was an accident of the bbox test.g.intersection.exists(line, line)intentionally left unchanged (stillfalsefor collinear overlap).Changesets:
minorforg.Line,patchforconnectors.Jumpover.Test plan
karma:geometry— 353/353; newisCollinear(line)module (partial overlap, containment, identical, reversed, touching, disjoint collinear, diagonal, parallel offset, crossing, perpendicular T-junction, shared endpoint only, zero-length on/off line in both call orders). Watched failing first (isCollinear is not a function).karma:joint— 2113/2113, incl.jumpover connector - stacked links do not cause jumps.grunt test:ts🤖 Generated with Claude Code