mirror of
https://github.com/Doodle3D/Doodle3D-Slicer.git
synced 2024-11-24 22:47:58 +01:00
reformat
This commit is contained in:
parent
3944202a83
commit
fc3dc7355c
@ -54,15 +54,15 @@ function createGraph(polygons) {
|
|||||||
const nextPoint = nextPoints.get(a);
|
const nextPoint = nextPoints.get(a);
|
||||||
const previousPoint = previousPoints.get(a);
|
const previousPoint = previousPoints.get(a);
|
||||||
|
|
||||||
if (lineIsVisible(previousPoint, nextPoint, edges, a, b)) {
|
if (!lineIsVisible(previousPoint, nextPoint, edges, a, b)) continue;
|
||||||
const distance = distanceTo(a, b);
|
|
||||||
|
|
||||||
const connectNodeA = graph[i];
|
const distance = distanceTo(a, b);
|
||||||
connectNodeA.push({ to: j, distance });
|
|
||||||
|
|
||||||
const connectNodeB = graph[j];
|
const connectNodeA = graph[i];
|
||||||
connectNodeB.push({ to: i, distance });
|
connectNodeA.push({ to: j, distance });
|
||||||
}
|
|
||||||
|
const connectNodeB = graph[j];
|
||||||
|
connectNodeB.push({ to: i, distance });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { graph, edges, points };
|
return { graph, edges, points };
|
||||||
@ -86,8 +86,8 @@ function createNode(graph, points, edges, point) {
|
|||||||
if (!lineIsVisible(previousPoint, nextPoint, edges, point, b)) continue;
|
if (!lineIsVisible(previousPoint, nextPoint, edges, point, b)) continue;
|
||||||
|
|
||||||
const distance = distanceTo(point, b);
|
const distance = distanceTo(point, b);
|
||||||
node.push({ to: i, distance });
|
|
||||||
|
|
||||||
|
node.push({ to: i, distance });
|
||||||
graph[i] = [...graph[i], { to, distance }];
|
graph[i] = [...graph[i], { to, distance }];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,6 +101,7 @@ function lineIsVisible(previousPoint, nextPoint, edges, a, b) {
|
|||||||
const angleLine = angle(subtract(b, a));
|
const angleLine = angle(subtract(b, a));
|
||||||
const anglePrevious = angle(subtract(previousPoint, a));
|
const anglePrevious = angle(subtract(previousPoint, a));
|
||||||
const angleNext = angle(subtract(nextPoint, a));
|
const angleNext = angle(subtract(nextPoint, a));
|
||||||
|
|
||||||
if (betweenAngles(angleLine, anglePrevious, angleNext)) return false;
|
if (betweenAngles(angleLine, anglePrevious, angleNext)) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,7 +150,10 @@ function shortestPath(graph, start, end) {
|
|||||||
const distances = graph.map(() => Infinity);
|
const distances = graph.map(() => Infinity);
|
||||||
distances[start] = 0;
|
distances[start] = 0;
|
||||||
const traverse = [];
|
const traverse = [];
|
||||||
const queue = graph.map((node, i) => i);
|
const queue = [];
|
||||||
|
for (let i = 0; i < distances.length; i ++) {
|
||||||
|
queue.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
while (queue.length > 0) {
|
while (queue.length > 0) {
|
||||||
let queueIndex;
|
let queueIndex;
|
||||||
|
Loading…
Reference in New Issue
Block a user