Repository navigation
Fix arc track hit test for arcs crossing 0 degrees - #589
Merged
Merged
Conversation
When an arc's normalized start angle is greater than its end angle the arc wraps through 0 and covers angles >= start or <= end. The check had the two angles swapped, which is true for every angle, so clicking anywhere on the arc's full circle within the track width selected its net. Co-Authored-By: Claude Opus 5.5 <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.
pointWithinDistanceToArc(web/render.js), used bynetHitScanto find the net under a click on arc tracks, normalizes the start and end angles to[0, 2π)and then checks whether the click angle falls inside the arc. Arc tracks are drawn withctx.arc(center, r, start, end), i.e. going from start with increasing angle to end. When the normalized start is greater than the end, the arc wraps through 0 and coversangle >= start || angle <= end.The wrap-around branch had the angles swapped:
Since
angle2 < angle1, every angle satisfies one side, so for any arc crossing 0° a click anywhere on its full circle (within the track width) selected the arc's net. Arcs not crossing 0° were unaffected.The fix swaps the comparison to
angle >= angle1 || angle <= angle2.Testing
I loaded
pointWithinDistanceToArcfrom master and from this branch in Node and evaluated 24 points (every 15°) on each arc's circle against the range covered byctx.arc(start, end):The reported case, a click at 180° on a -10°..10° arc, returned
trueon master and returnsfalsenow. Points off the circle are rejected by both versions as before.🤖 Generated with Claude Code