Visitar URL original
Fix fillet fitting and tangent continuity for lines and arcs by takuto-NA · Pull Request #676 · microsoft/maker.js · GitHub
Skip to content

Fix fillet fitting and tangent continuity for lines and arcs - #676

Open
takuto-NA wants to merge 1 commit into
microsoft:masterfrom
takuto-NA:codex/fillet-robustness
Open

takuto-NA wants to merge 1 commit into
microsoft:masterfrom
takuto-NA:codex/fillet-robustness

Conversation

@takuto-NA

@takuto-NA takuto-NA commented Nov 9, 2026 •

Copy link
Copy Markdown

Filleting short, nearly collinear lines currently returns null even when the tangent points fit inside both segments. With arcs, selecting guides from a radius-sized sample can also produce a tangent reversal or trim the wrong part of a major arc.

Determine offset guides from endpoint tangents, using signed curvature for equal-tangent cusps. Intersect their supporting lines/circles without fixed-unit coordinate rounding, then accept only candidates whose tangent points stay within both original paths, connect accurately, and preserve tangent direction. Honor pointMatchingDistance and reject unsupported, nonfinite, or degenerate inputs without mutation.

For example, these unit-length segments can accommodate a radius-2 fillet; the current reference-circle check rejects it:

const a = new makerjs.paths.Line([0, 0], [1, 0]);
const b = new makerjs.paths.Line([0, 0], [Math.cos(170 * Math.PI / 180), Math.sin(170 * Math.PI / 180)]);
const fillet = makerjs.path.fillet(a, b, 2);

Validation

  • Full root npm test, including every workspace build, 158 tests, build tools, and documentation generation, passed on Windows with Node 20.20.2 / npm 10.8.2 and Node 22.23.4 / npm 10.9.9.
  • MAKERJS_FILLET_STRESS_CASES=100000 npm run test-fillet --workspace=makerjs passed: 34 test groups, including 1,600,000 deterministic generated path pairs.
  • GitHub's Linux Node 20/22 workflow is awaiting maintainer approval for this fork's pull request; no CI jobs have run yet.
  • Regression checks cover documented Arc/Arc and Arc/Line cusp examples, endpoint combinations and argument order, tiny/large scales, negative and wrapped angles, extreme size ratios, failure without input mutation, nested origins, directional radii, a 2,000-path chain, and SVG/DXF output.
  • Reviewed candidate selection, tangent orientation, finite-path trimming, rollback of temporary clips, precision rejection, and shared dogbone endpoint matching. Generated files and lockfile changes are excluded.

This remains a local corner operation; it does not check collisions against unrelated paths. Numerically ill-conditioned candidates can return null rather than an inaccurate fillet. The contributor will handle CLA consent separately.

@takuto-NA

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@takuto-NA
takuto-NA marked this pull request as ready for review November 9, 2026 11:09
@danmarshall

Copy link
Copy Markdown
Contributor

takuto-NA thanks for the contribution! 🙏 I'll add comments inline.

This branch has not been deployed

No deployments
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.

2 participants