test(junction): cover six-arm rotation stability
This commit is contained in:
1 parent
f18dd0c0eb
commit
234dd46f59
1 file changed
+33
@@ -195,4 +195,37 @@ const curvedBoundaryStation = stationAtDistanceFrom(curvedBoundaryLine, point(0,
|
||||
});
|
||||
assert.ok(Math.abs(distance(pointAtStation(curvedBoundaryLine, curvedBoundaryStation), point(0, 0)) - 9) < 0.01);
|
||||
|
||||
// Six-arm clusters remain within the supported matrix and keep semantic keys
|
||||
// stable when the source geometry is rotated. Geometry may change with the
|
||||
// transform, but identity and arm count must not depend on input orientation.
|
||||
const sixArmEntries = [0, 60, 120, 180, 240, 300].map((angle) => ({
|
||||
widthMeters: 6,
|
||||
line: [point(0, 0), point(Math.sin((angle * Math.PI) / 180) * 45, Math.cos((angle * Math.PI) / 180) * 45)],
|
||||
}));
|
||||
const sixArm = topology('six-arm', sixArmEntries);
|
||||
assert.equal(sixArm.topology.arms.length, 6);
|
||||
assert.equal(classifyJunctionShape(sixArm.topology.arms, point(0, 0), sixArm.helpers).kind, 'multi-arm');
|
||||
const sixArmGraph = buildJunctionBoundaryGraph(
|
||||
sixArm.topology,
|
||||
point(0, 0),
|
||||
{ outerRadiusFor: () => 30, innerRadiusFor: () => 10 },
|
||||
sixArm.helpers,
|
||||
);
|
||||
assert.equal(buildCoreClosure(sixArm.topology, sixArmGraph, point(0, 0)).status, 'supported');
|
||||
const rotate = (coordinate, degrees) => {
|
||||
const radians = (degrees * Math.PI) / 180;
|
||||
return point(
|
||||
coordinate[0] * metersPerDegree * Math.cos(radians) - coordinate[1] * metersPerDegree * Math.sin(radians),
|
||||
coordinate[0] * metersPerDegree * Math.sin(radians) + coordinate[1] * metersPerDegree * Math.cos(radians),
|
||||
);
|
||||
};
|
||||
const rotatedSixArmEntries = sixArmEntries.map((entry) => ({
|
||||
...entry,
|
||||
line: entry.line.map((coordinate) => rotate(coordinate, 37)),
|
||||
}));
|
||||
const rotatedSixArm = fixture('six-arm', rotatedSixArmEntries);
|
||||
const rotatedTopology = resolveJunctionBuildPlan(rotatedSixArm.model, rotatedSixArm.cluster, rotatedSixArm.helpers);
|
||||
assert.deepEqual(rotatedTopology.arms.map((arm) => arm.key).sort(), sixArm.topology.arms.map((arm) => arm.key).sort());
|
||||
assert.equal(rotatedTopology.arms.length, sixArm.topology.arms.length);
|
||||
|
||||
console.log('junction build-plan counterexample tests passed');
|
||||
Reference in new issue
Block a user