microboard-temp 0.5.77 → 0.5.78
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +4 -42
- package/dist/cjs/index.js +4 -42
- package/dist/cjs/node.js +4 -42
- package/dist/esm/browser.js +4 -42
- package/dist/esm/index.js +4 -42
- package/dist/esm/node.js +4 -42
- package/package.json +1 -1
package/dist/cjs/browser.js
CHANGED
|
@@ -36727,38 +36727,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36727
36727
|
}
|
|
36728
36728
|
return neighbors;
|
|
36729
36729
|
}
|
|
36730
|
-
function findCenterLine(grid, start, end, middle) {
|
|
36731
|
-
const centerLine = [];
|
|
36732
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
36733
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
36734
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
36735
|
-
const width = max2.x - min2.x;
|
|
36736
|
-
const height = max2.y - min2.y;
|
|
36737
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
36738
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
36739
|
-
return isInGrid ? [middlePoint] : [];
|
|
36740
|
-
}
|
|
36741
|
-
if (width > height) {
|
|
36742
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
36743
|
-
if (centerIdx !== -1) {
|
|
36744
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
36745
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
36746
|
-
centerLine.push(grid[centerIdx][y]);
|
|
36747
|
-
}
|
|
36748
|
-
}
|
|
36749
|
-
}
|
|
36750
|
-
} else {
|
|
36751
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
36752
|
-
if (centerIdx !== -1) {
|
|
36753
|
-
for (let x = 0;x < grid.length; x++) {
|
|
36754
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
36755
|
-
centerLine.push(grid[x][centerIdx]);
|
|
36756
|
-
}
|
|
36757
|
-
}
|
|
36758
|
-
}
|
|
36759
|
-
}
|
|
36760
|
-
return centerLine;
|
|
36761
|
-
}
|
|
36762
36730
|
function createGrid(start, end, toVisitPoints = []) {
|
|
36763
36731
|
const startDir = getPointerDirection(start);
|
|
36764
36732
|
const endDir = getPointerDirection(end);
|
|
@@ -36967,16 +36935,10 @@ function reconstructPath(node2) {
|
|
|
36967
36935
|
return path2.reverse();
|
|
36968
36936
|
}
|
|
36969
36937
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36970
|
-
const { grid, newStart, newEnd
|
|
36971
|
-
const startPoint = newStart
|
|
36972
|
-
const endPoint = newEnd
|
|
36973
|
-
const
|
|
36974
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
36975
|
-
const points = [
|
|
36976
|
-
startPoint,
|
|
36977
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
36978
|
-
endPoint
|
|
36979
|
-
];
|
|
36938
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36939
|
+
const startPoint = newStart || start;
|
|
36940
|
+
const endPoint = newEnd || end;
|
|
36941
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
36980
36942
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36981
36943
|
return {
|
|
36982
36944
|
lines: getLines(pathPoints),
|
package/dist/cjs/index.js
CHANGED
|
@@ -36727,38 +36727,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36727
36727
|
}
|
|
36728
36728
|
return neighbors;
|
|
36729
36729
|
}
|
|
36730
|
-
function findCenterLine(grid, start, end, middle) {
|
|
36731
|
-
const centerLine = [];
|
|
36732
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
36733
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
36734
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
36735
|
-
const width = max2.x - min2.x;
|
|
36736
|
-
const height = max2.y - min2.y;
|
|
36737
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
36738
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
36739
|
-
return isInGrid ? [middlePoint] : [];
|
|
36740
|
-
}
|
|
36741
|
-
if (width > height) {
|
|
36742
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
36743
|
-
if (centerIdx !== -1) {
|
|
36744
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
36745
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
36746
|
-
centerLine.push(grid[centerIdx][y]);
|
|
36747
|
-
}
|
|
36748
|
-
}
|
|
36749
|
-
}
|
|
36750
|
-
} else {
|
|
36751
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
36752
|
-
if (centerIdx !== -1) {
|
|
36753
|
-
for (let x = 0;x < grid.length; x++) {
|
|
36754
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
36755
|
-
centerLine.push(grid[x][centerIdx]);
|
|
36756
|
-
}
|
|
36757
|
-
}
|
|
36758
|
-
}
|
|
36759
|
-
}
|
|
36760
|
-
return centerLine;
|
|
36761
|
-
}
|
|
36762
36730
|
function createGrid(start, end, toVisitPoints = []) {
|
|
36763
36731
|
const startDir = getPointerDirection(start);
|
|
36764
36732
|
const endDir = getPointerDirection(end);
|
|
@@ -36967,16 +36935,10 @@ function reconstructPath(node2) {
|
|
|
36967
36935
|
return path2.reverse();
|
|
36968
36936
|
}
|
|
36969
36937
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36970
|
-
const { grid, newStart, newEnd
|
|
36971
|
-
const startPoint = newStart
|
|
36972
|
-
const endPoint = newEnd
|
|
36973
|
-
const
|
|
36974
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
36975
|
-
const points = [
|
|
36976
|
-
startPoint,
|
|
36977
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
36978
|
-
endPoint
|
|
36979
|
-
];
|
|
36938
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36939
|
+
const startPoint = newStart || start;
|
|
36940
|
+
const endPoint = newEnd || end;
|
|
36941
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
36980
36942
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36981
36943
|
return {
|
|
36982
36944
|
lines: getLines(pathPoints),
|
package/dist/cjs/node.js
CHANGED
|
@@ -39200,38 +39200,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
39200
39200
|
}
|
|
39201
39201
|
return neighbors;
|
|
39202
39202
|
}
|
|
39203
|
-
function findCenterLine(grid, start, end, middle) {
|
|
39204
|
-
const centerLine = [];
|
|
39205
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
39206
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
39207
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
39208
|
-
const width = max2.x - min2.x;
|
|
39209
|
-
const height = max2.y - min2.y;
|
|
39210
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
39211
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
39212
|
-
return isInGrid ? [middlePoint] : [];
|
|
39213
|
-
}
|
|
39214
|
-
if (width > height) {
|
|
39215
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
39216
|
-
if (centerIdx !== -1) {
|
|
39217
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
39218
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
39219
|
-
centerLine.push(grid[centerIdx][y]);
|
|
39220
|
-
}
|
|
39221
|
-
}
|
|
39222
|
-
}
|
|
39223
|
-
} else {
|
|
39224
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
39225
|
-
if (centerIdx !== -1) {
|
|
39226
|
-
for (let x = 0;x < grid.length; x++) {
|
|
39227
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
39228
|
-
centerLine.push(grid[x][centerIdx]);
|
|
39229
|
-
}
|
|
39230
|
-
}
|
|
39231
|
-
}
|
|
39232
|
-
}
|
|
39233
|
-
return centerLine;
|
|
39234
|
-
}
|
|
39235
39203
|
function createGrid(start, end, toVisitPoints = []) {
|
|
39236
39204
|
const startDir = getPointerDirection(start);
|
|
39237
39205
|
const endDir = getPointerDirection(end);
|
|
@@ -39440,16 +39408,10 @@ function reconstructPath(node2) {
|
|
|
39440
39408
|
return path2.reverse();
|
|
39441
39409
|
}
|
|
39442
39410
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39443
|
-
const { grid, newStart, newEnd
|
|
39444
|
-
const startPoint = newStart
|
|
39445
|
-
const endPoint = newEnd
|
|
39446
|
-
const
|
|
39447
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
39448
|
-
const points = [
|
|
39449
|
-
startPoint,
|
|
39450
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
39451
|
-
endPoint
|
|
39452
|
-
];
|
|
39411
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
39412
|
+
const startPoint = newStart || start;
|
|
39413
|
+
const endPoint = newEnd || end;
|
|
39414
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
39453
39415
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39454
39416
|
return {
|
|
39455
39417
|
lines: getLines(pathPoints),
|
package/dist/esm/browser.js
CHANGED
|
@@ -36572,38 +36572,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36572
36572
|
}
|
|
36573
36573
|
return neighbors;
|
|
36574
36574
|
}
|
|
36575
|
-
function findCenterLine(grid, start, end, middle) {
|
|
36576
|
-
const centerLine = [];
|
|
36577
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
36578
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
36579
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
36580
|
-
const width = max2.x - min2.x;
|
|
36581
|
-
const height = max2.y - min2.y;
|
|
36582
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
36583
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
36584
|
-
return isInGrid ? [middlePoint] : [];
|
|
36585
|
-
}
|
|
36586
|
-
if (width > height) {
|
|
36587
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
36588
|
-
if (centerIdx !== -1) {
|
|
36589
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
36590
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
36591
|
-
centerLine.push(grid[centerIdx][y]);
|
|
36592
|
-
}
|
|
36593
|
-
}
|
|
36594
|
-
}
|
|
36595
|
-
} else {
|
|
36596
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
36597
|
-
if (centerIdx !== -1) {
|
|
36598
|
-
for (let x = 0;x < grid.length; x++) {
|
|
36599
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
36600
|
-
centerLine.push(grid[x][centerIdx]);
|
|
36601
|
-
}
|
|
36602
|
-
}
|
|
36603
|
-
}
|
|
36604
|
-
}
|
|
36605
|
-
return centerLine;
|
|
36606
|
-
}
|
|
36607
36575
|
function createGrid(start, end, toVisitPoints = []) {
|
|
36608
36576
|
const startDir = getPointerDirection(start);
|
|
36609
36577
|
const endDir = getPointerDirection(end);
|
|
@@ -36812,16 +36780,10 @@ function reconstructPath(node2) {
|
|
|
36812
36780
|
return path2.reverse();
|
|
36813
36781
|
}
|
|
36814
36782
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36815
|
-
const { grid, newStart, newEnd
|
|
36816
|
-
const startPoint = newStart
|
|
36817
|
-
const endPoint = newEnd
|
|
36818
|
-
const
|
|
36819
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
36820
|
-
const points = [
|
|
36821
|
-
startPoint,
|
|
36822
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
36823
|
-
endPoint
|
|
36824
|
-
];
|
|
36783
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36784
|
+
const startPoint = newStart || start;
|
|
36785
|
+
const endPoint = newEnd || end;
|
|
36786
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
36825
36787
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36826
36788
|
return {
|
|
36827
36789
|
lines: getLines(pathPoints),
|
package/dist/esm/index.js
CHANGED
|
@@ -36565,38 +36565,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
36565
36565
|
}
|
|
36566
36566
|
return neighbors;
|
|
36567
36567
|
}
|
|
36568
|
-
function findCenterLine(grid, start, end, middle) {
|
|
36569
|
-
const centerLine = [];
|
|
36570
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
36571
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
36572
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
36573
|
-
const width = max2.x - min2.x;
|
|
36574
|
-
const height = max2.y - min2.y;
|
|
36575
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
36576
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
36577
|
-
return isInGrid ? [middlePoint] : [];
|
|
36578
|
-
}
|
|
36579
|
-
if (width > height) {
|
|
36580
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
36581
|
-
if (centerIdx !== -1) {
|
|
36582
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
36583
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
36584
|
-
centerLine.push(grid[centerIdx][y]);
|
|
36585
|
-
}
|
|
36586
|
-
}
|
|
36587
|
-
}
|
|
36588
|
-
} else {
|
|
36589
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
36590
|
-
if (centerIdx !== -1) {
|
|
36591
|
-
for (let x = 0;x < grid.length; x++) {
|
|
36592
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
36593
|
-
centerLine.push(grid[x][centerIdx]);
|
|
36594
|
-
}
|
|
36595
|
-
}
|
|
36596
|
-
}
|
|
36597
|
-
}
|
|
36598
|
-
return centerLine;
|
|
36599
|
-
}
|
|
36600
36568
|
function createGrid(start, end, toVisitPoints = []) {
|
|
36601
36569
|
const startDir = getPointerDirection(start);
|
|
36602
36570
|
const endDir = getPointerDirection(end);
|
|
@@ -36805,16 +36773,10 @@ function reconstructPath(node2) {
|
|
|
36805
36773
|
return path2.reverse();
|
|
36806
36774
|
}
|
|
36807
36775
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
36808
|
-
const { grid, newStart, newEnd
|
|
36809
|
-
const startPoint = newStart
|
|
36810
|
-
const endPoint = newEnd
|
|
36811
|
-
const
|
|
36812
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
36813
|
-
const points = [
|
|
36814
|
-
startPoint,
|
|
36815
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
36816
|
-
endPoint
|
|
36817
|
-
];
|
|
36776
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
36777
|
+
const startPoint = newStart || start;
|
|
36778
|
+
const endPoint = newEnd || end;
|
|
36779
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
36818
36780
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
36819
36781
|
return {
|
|
36820
36782
|
lines: getLines(pathPoints),
|
package/dist/esm/node.js
CHANGED
|
@@ -39033,38 +39033,6 @@ function getNeighbors(node2, grid, obstacles) {
|
|
|
39033
39033
|
}
|
|
39034
39034
|
return neighbors;
|
|
39035
39035
|
}
|
|
39036
|
-
function findCenterLine(grid, start, end, middle) {
|
|
39037
|
-
const centerLine = [];
|
|
39038
|
-
const middlePoint = middle ? middle : new Point((start.x + end.x) / 2, (start.y + end.y) / 2);
|
|
39039
|
-
const min2 = new Point(Math.min(start.x, end.x), Math.min(start.y, end.y));
|
|
39040
|
-
const max2 = new Point(Math.max(start.x, end.x), Math.max(start.y, end.y));
|
|
39041
|
-
const width = max2.x - min2.x;
|
|
39042
|
-
const height = max2.y - min2.y;
|
|
39043
|
-
if (start.pointType !== "Board" && end.pointType !== "Board") {
|
|
39044
|
-
const isInGrid = grid.some((row2) => row2.some((point5) => point5.barelyEqual(middlePoint)));
|
|
39045
|
-
return isInGrid ? [middlePoint] : [];
|
|
39046
|
-
}
|
|
39047
|
-
if (width > height) {
|
|
39048
|
-
const centerIdx = grid.findIndex((row2) => row2[0].x === middlePoint.x || Math.abs(row2[0].x - middlePoint.x) < 0.01);
|
|
39049
|
-
if (centerIdx !== -1) {
|
|
39050
|
-
for (let y = 0;y < grid[0].length; y++) {
|
|
39051
|
-
if (grid[centerIdx][y] && grid[centerIdx][y].x >= min2.x - 0.01 && grid[centerIdx][y].x <= max2.x + 0.01 && grid[centerIdx][y].y >= min2.y - 0.01 && grid[centerIdx][y].y <= max2.y + 0.01) {
|
|
39052
|
-
centerLine.push(grid[centerIdx][y]);
|
|
39053
|
-
}
|
|
39054
|
-
}
|
|
39055
|
-
}
|
|
39056
|
-
} else {
|
|
39057
|
-
const centerIdx = grid[0].findIndex((point5) => point5.y === middlePoint.y || Math.abs(point5.y - middlePoint.y) < 0.01);
|
|
39058
|
-
if (centerIdx !== -1) {
|
|
39059
|
-
for (let x = 0;x < grid.length; x++) {
|
|
39060
|
-
if (grid[x][centerIdx] && grid[x][centerIdx].x >= min2.x - 0.01 && grid[x][centerIdx].x <= max2.x + 0.01 && grid[x][centerIdx].y >= min2.y - 0.01 && grid[x][centerIdx].y <= max2.y + 0.01) {
|
|
39061
|
-
centerLine.push(grid[x][centerIdx]);
|
|
39062
|
-
}
|
|
39063
|
-
}
|
|
39064
|
-
}
|
|
39065
|
-
}
|
|
39066
|
-
return centerLine;
|
|
39067
|
-
}
|
|
39068
39036
|
function createGrid(start, end, toVisitPoints = []) {
|
|
39069
39037
|
const startDir = getPointerDirection(start);
|
|
39070
39038
|
const endDir = getPointerDirection(end);
|
|
@@ -39273,16 +39241,10 @@ function reconstructPath(node2) {
|
|
|
39273
39241
|
return path2.reverse();
|
|
39274
39242
|
}
|
|
39275
39243
|
function findOrthogonalPath(start, end, obstacles, toVisitPoints = []) {
|
|
39276
|
-
const { grid, newStart, newEnd
|
|
39277
|
-
const startPoint = newStart
|
|
39278
|
-
const endPoint = newEnd
|
|
39279
|
-
const
|
|
39280
|
-
const adjustedCenterLine = centerLine.length > 0 ? startPoint.getDistance(centerLine[0]) < startPoint.getDistance(centerLine[centerLine.length - 1]) ? centerLine : centerLine.reverse() : centerLine;
|
|
39281
|
-
const points = [
|
|
39282
|
-
startPoint,
|
|
39283
|
-
...toVisitPoints.length > 0 ? toVisitPoints : adjustedCenterLine,
|
|
39284
|
-
endPoint
|
|
39285
|
-
];
|
|
39244
|
+
const { grid, newStart, newEnd } = createGrid(start, end, toVisitPoints);
|
|
39245
|
+
const startPoint = newStart || start;
|
|
39246
|
+
const endPoint = newEnd || end;
|
|
39247
|
+
const points = [startPoint, ...toVisitPoints, endPoint];
|
|
39286
39248
|
const pathPoints = findPathPoints(points, grid, obstacles, newStart, newEnd);
|
|
39287
39249
|
return {
|
|
39288
39250
|
lines: getLines(pathPoints),
|