fix: orient pair short side along primary axis before convergence

The convergence loop now ensures the pair starts with its short side
parallel to the primary axis, maximizing the number of pairs that fit.
Also adds ConvergeStripeAngleShrink to try N+1 narrower pairs, and
evaluates both expand and shrink results to pick the better grid.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-03-21 09:22:13 -04:00
parent 811d23510e
commit 3f3d95a5e4
2 changed files with 166 additions and 37 deletions

View File

@@ -114,12 +114,13 @@ public class StripeFillerTests
[Fact]
public void ConvergeStripeAngle_HandlesExactFit()
{
// 10x5 pattern: short side (5) oriented along axis, so more pairs fit
var pattern = MakeRectPattern(10, 5);
var (angle, waste, count) = StripeFiller.ConvergeStripeAngle(
pattern.Parts, 100.0, 0.0, NestDirection.Horizontal);
Assert.Equal(10, count);
Assert.True(waste < 0.2, $"Expected near-zero waste, got {waste:F2}");
Assert.True(count >= 10, $"Expected at least 10 pairs, got {count}");
Assert.True(waste < 1.0, $"Expected low waste, got {waste:F2}");
}
[Fact]