feat: solve complete junction island contacts

This commit is contained in:
que01 committed 2026-09-14 08:59:32 +08:00
1 parent 7a7912f302
commit 1b91e280bc
5 files changed
+164 -7

No files matched your search

+19 -1
View File
@@ -75,7 +75,7 @@ for (let i = 1; i < 4; i++) assert.ok(Math.abs(fitted[i] - fitted[i - 1] - 90) <
assert.deepEqual(orthogonalCrossingHeadings([0, 120, 240]), [0, 120, 240]);
assert.deepEqual(orthogonalCrossingHeadings([0, 40, 180, 270]), [0, 40, 180, 270]);
const { crossingArcSupport } = require('../src/compile/junction-facility-composition');
const { crossingArcSupport, solveIslandContacts } = require('../src/compile/junction-facility-composition');
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 0), 'right-angle vertex is rounded');
assert.ok(!sketchIsland.some(([x, y]) => x === 0 && y === 6.8), 'first arc/leg vertex is rounded');
assert.ok(!sketchIsland.some(([x, y]) => x === -6.8 && y === 0), 'second arc/leg vertex is rounded');
@@ -105,3 +105,21 @@ assert.deepEqual(
),
[],
);
const solvedContacts = solveIslandContacts(
[
[0, 0],
[0, 6.8],
],
[
[0, 0],
[-6.8, 0],
],
3.4,
{ maxLegLength: 20 },
);
assert.equal(solvedContacts.status, 'solved');
assert.equal(solvedContacts.contacts.length, 3);
assert.equal(solvedContacts.greenRing.length, 7);
assert.equal(solvedContacts.legLengths.length, 2);
assert.ok(solvedContacts.legLengths.every((value) => value > 6.8));