Skip to content

fix: visualizer renders G18 radius-format arcs correctly - #157

Merged
misiekhardcore merged 6 commits into
mainfrom
forge/ws-c488e45b
Aug 17, 2026
Merged

misiekhardcore merged 6 commits into
mainfrom
forge/ws-c488e45b

Conversation

@misiekhardcore

Copy link
Copy Markdown
Contributor

Summary

Fixes the visualizer rendering G18 (ZX) plane arcs as straight lines. Reported with clamex_p14_slot.nc - a three-pass semicircular groove carved via G18 + G2 X±w Z0 R50.376 that rendered as 3 straight lines.

Two bugs fixed:

  1. Radius-format (R-word) arcs were ignored. The extractor only read I/J/K center offsets; G2 X21.881 Z0.000 R50.376 had no offsets, so the computed radius was 0 and the arc degenerated into a straight line. Added resolveArcOffsetsFromRadius, 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 shared computeArcSweep helper deduplicates the sweep normalization with generateArcPoints. 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.

  2. 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

  • The reported file pattern now extracts 3 ARC_CW segments dipping to Z = −5.0 / −10.0 / −14.0 mm - verified both via a synthetic regression test mirroring clamex_p14_slot.nc and by running the actual file through the fixed extractor.
  • New tests: G18 direction (G2 dips below the chord, G3 bulges above), G17/G19 regression guards, R-word arcs in all three planes, positive/negative R (short/long arcs) for both G2 and G3, exact-semicircle negative R, G91 incremental, impossible-radius fallback, I/J/K-over-R precedence, and the clamex 3-pass groove test with sampling-robust depth bounds.
  • Validation: tsc --noEmit clean; extractor suite 91/91; full unit suite 85 suites / 1417 tests; lint clean on touched files; e2e suite 96 passing.

AC checklist

  • R-word (radius-format) G2/G3 arcs render as interpolated arc segments in G17, G18, G19
  • Negative R renders the long arc; positive R renders the short arc
  • G18 arc direction follows the standard convention (G2 dips below the chord as viewed from +Y)
  • The clamex 3-pass pattern renders as 3 semicircular passes at Z = −5 / −10 / −14
  • Existing behavior preserved: I/J/K offset arcs unchanged; no-offset/no-R and impossible-R cases still degrade to a straight line
  • CHANGELOG updated; lint, typecheck, unit suite green

Commits

  • 657503b fix: correct inverted G18 (XZ) arc direction in visualizer path extractor
  • 1c61b9a fix: render radius-format (R-word) G2/G3 arcs as arcs in visualizer
  • 8e9562b fix: render negative-R semicircles and deduplicate arc sweep computation
  • f56c8b3 test: harden clamex groove-depth assertions against arc sampling parity

@misiekhardcore
misiekhardcore merged commit 3fa9fb9 into main Aug 17, 2026
7 checks passed
@misiekhardcore
misiekhardcore deleted the forge/ws-c488e45b branch August 17, 2026 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant