fix: visualizer renders G18 radius-format arcs correctly - #157
Merged
Merged
Conversation
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
Fixes the visualizer rendering G18 (ZX) plane arcs as straight lines. Reported with
clamex_p14_slot.nc- a three-pass semicircular groove carved viaG18+G2 X±w Z0 R50.376that rendered as 3 straight lines.Two bugs fixed:
Radius-format (R-word) arcs were ignored. The extractor only read I/J/K center offsets;
G2 X21.881 Z0.000 R50.376had no offsets, so the computed radius was 0 and the arc degenerated into a straight line. AddedresolveArcOffsetsFromRadius, which reconstructs the arc center from chord geometry and picks the candidate whose sweep matches the G2/G3 direction and the R sign (positive R = short arc <= 180°, negative R = long arc > 180°). A sharedcomputeArcSweephelper deduplicates the sweep normalization withgenerateArcPoints. Fallbacks: I/J/K offsets take precedence when non-zero; impossible geometry (|R| < chord/2, zero radius, start == end) still degrades to a straight line.G18 arc direction was inverted. The XZ plane config used a left-handed in-plane axis order (X, Z). The standard convention (CW/CCW as viewed from +Y, per LinuxCNC/NIST) requires the cyclic order (Z, X) so the interpolation angle increases CCW about the positive normal axis uniformly in all three planes. Swapped the config to (z, x) with K/I offsets; G17 and G19 untouched.
Verification
ARC_CWsegments dipping to Z = −5.0 / −10.0 / −14.0 mm - verified both via a synthetic regression test mirroringclamex_p14_slot.ncand by running the actual file through the fixed extractor.tsc --noEmitclean; extractor suite 91/91; full unit suite 85 suites / 1417 tests; lint clean on touched files; e2e suite 96 passing.AC checklist
Commits
657503bfix: correct inverted G18 (XZ) arc direction in visualizer path extractor1c61b9afix: render radius-format (R-word) G2/G3 arcs as arcs in visualizer8e9562bfix: render negative-R semicircles and deduplicate arc sweep computationf56c8b3test: harden clamex groove-depth assertions against arc sampling parity