Fix sliceIntoLayers missing segments for near-parallel edges #39
+188
−8
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.
sliceIntoLayersfails to detect intersections when triangle edges are nearly parallel to the slice plane (< 1° angle), causing 0.6-5.8mm gaps in generated segments. This breaks path closure in 3D printing slicers like polyslice on geometries like Benchy.Root Cause
Exact floating-point equality checks skip edges with distances like
1e-15:Changes
Angle-aware adaptive epsilon
dotWithNormal < 0.02(~1° threshold)max(1e-10, length * 1e-9)Replace exact comparisons
Fix parameter validation
minZ == maxZfor single-plane slicing (was incorrectly rejected)Test Coverage
Added 4 cases: near-parallel edges (2e-7 tolerance), tiny distances (1e-10), long edges (200+ units), duplicate prevention.
Example from new tests:
All 507 tests pass (503 existing + 4 new).
References
NEAR_PARALLEL_EDGE_FIX.mdfor detailed technical explanationWarning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
https://api.github.com/repos/jgphilpott/polyslice/pulls/69curl -s REDACTED(http block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.