Implement acute angle detection for orthogonal link labels with AutoRight/AutoLeft#271
Merged
ugwis merged 12 commits intoawslabs:mainfrom Jan 14, 2026
Merged
Implement acute angle detection for orthogonal link labels with AutoRight/AutoLeft#271ugwis merged 12 commits intoawslabs:mainfrom
ugwis merged 12 commits intoawslabs:mainfrom
Conversation
- Add Right/Left auto-positioning labels documentation - Add explanation for longest horizontal segment detection in orthogonal links - Update Link Labels section with complete label positioning options
- Add Cross product method to Vector for 2D cross product calculation - Implement findPerpendicularSegments to detect 90-degree angles using cross product - Add getAcuteAngleSide to determine Left/Right acute angle sides independently - Update label placement logic to reverse parameters when acute angles detected: - Reverse source/target, autoPt1/autoPt2, Left/Right, and autoPos direction - Use (autoPos + 8) % 16 for 180-degree autoPos rotation - Add comprehensive tests for autoPos reversal and acute angle detection - Fix existing test expectations for correct cross product calculations This improves label placement on orthogonal links by positioning labels on the acute angle side of the longest horizontal segment for better visual clarity.
- Update LinkLabels struct to use AutoRight/AutoLeft instead of Right/Left - Modify label processing logic to use new field names - Update YAML parsing and conversion to support AutoRight/AutoLeft - Update test YAML file to use new label names This change makes the auto-positioning nature of these labels more explicit and distinguishes them from fixed-position labels.
- Run go fmt to fix code formatting - Remove trailing whitespace and align comments properly
- Update TestAcuteAngleLabelPlacement to use AutoRight/AutoLeft instead of deprecated Right/Left fields - This fixes the compilation error in CI tests
- Improve segment selection to check angles both before and after horizontal segments - This allows detection of acute angles at the end of paths (before horizontal segment) - Maintains preference for segments with detectable acute angles when lengths are equal - Enables better label placement by considering all possible acute angle positions
…sition - Remove label reversal logic (no more source/target/side swapping) - Implement findBestSegmentForSideWithPosition() to detect acute angle position - Select segment based on acute angle position: * before (n-1 to n acute): use segment n * after (n to n+1 acute): use segment n+1 - Support vertical segments for label placement - Add autoPos calculation for vertical segments (North/South) - AutoLeft and AutoRight independently select optimal segments - Labels naturally avoid acute angles without reversal - Add TestSegmentSelectionBasedOnAcutePosition test case
- Update auto-positioning label names in links.md - Add description of acute angle avoidance behavior
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
This PR implements acute angle detection for orthogonal link labels to improve visual clarity by positioning labels on the acute angle side of the longest horizontal segment.
Changes
Core Implementation
Label Positioning Logic
New Label Types
Testing
Visual Impact
Labels are now positioned on the acute angle side of orthogonal links, providing:
Example Usage
Labels will automatically position themselves on the appropriate side based on acute angle detection.