feat: establish junction region geometry baseline
This commit is contained in:
1 parent
de97600fe8
commit
76f81d024a
14 files changed
+287
-11
No files matched your search
@@ -0,0 +1,26 @@
|
||||
'use strict';
|
||||
|
||||
const assert = require('assert/strict');
|
||||
const { difference, intersection, union, intersectsOrTouches } = require('../src/compile/junction-polygon-ops');
|
||||
|
||||
const square = (x, y, size) => [
|
||||
[
|
||||
[x, y],
|
||||
[x + size, y],
|
||||
[x + size, y + size],
|
||||
[x, y + size],
|
||||
[x, y],
|
||||
],
|
||||
];
|
||||
const shell = square(0, 0, 10);
|
||||
const hole = square(2, 2, 6);
|
||||
assert.equal(difference(shell, hole)[0].length, 2);
|
||||
assert.equal(intersection(shell, hole).length, 1);
|
||||
assert.equal(union(shell, square(10, 0, 5)).length, 1);
|
||||
assert.deepEqual(difference(shell), [shell]);
|
||||
assert.equal(intersectsOrTouches(shell, hole), true);
|
||||
assert.equal(
|
||||
intersectsOrTouches(shell, square(20, 0, 2), () => true),
|
||||
true,
|
||||
);
|
||||
console.log('junction polygon operation tests passed');
|
||||
Reference in new issue
Block a user