This commit is contained in:
John Gatward
2026-03-18 15:24:08 +00:00
parent 213cf5f535
commit 3cb8d5a14e
17 changed files with 1525 additions and 331 deletions

19
projects/tsp/utils.js Normal file
View File

@@ -0,0 +1,19 @@
// utils.js
export function initPoints(points) {
let cs = [];
for (let i = 0; i < points.length; i += 2) {
cs.push(new Point(points[i], points[i + 1]));
}
return cs;
}
export function updateLines(points, pointOrder) {
const lineVertices = [];
for (let i = 0; i < pointOrder.length - 1; i++) {
const j = pointOrder[i];
const k = pointOrder[i + 1];
lineVertices.push(points[j].cx * 2 - 1, points[j].cy * 2 - 1);
lineVertices.push(points[k].cx * 2 - 1, points[k].cy * 2 - 1);
}
return new Float32Array(lineVertices);
}