From fd6e5cebbd4d41f4e45ef724268e59dbe59c8b36 Mon Sep 17 00:00:00 2001 From: Casper Lamboo Date: Mon, 28 May 2018 13:53:09 +0200 Subject: [PATCH] remove normals --- src/sliceActions/helpers/comb.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/sliceActions/helpers/comb.js b/src/sliceActions/helpers/comb.js index a7fd1e1..d39d190 100644 --- a/src/sliceActions/helpers/comb.js +++ b/src/sliceActions/helpers/comb.js @@ -1,15 +1,15 @@ -import { angle, subtract, distanceTo, normal } from './vector2.js'; +import { angle, subtract, distanceTo } from './vector2.js'; const graphs = new WeakMap(); export default function comb(polygons, start, end) { if (!graphs.has(polygons)) graphs.set(polygons, createGraph(polygons)); - let { edges, graph, points, normals } = graphs.get(polygons); + let { edges, graph, points } = graphs.get(polygons); points = [...points, start, end]; graph = [...graph]; - const startNode = createNode(graph, points, edges, normals, start); - const endNode = createNode(graph, points, edges, normals, end); + const startNode = createNode(graph, points, edges, start); + const endNode = createNode(graph, points, edges, end); let result; if (graph[startNode].some(node => node.to === endNode)) { @@ -31,7 +31,6 @@ function createGraph(polygons) { const edges = []; const nextPoints = new WeakMap(); const previousPoints = new WeakMap(); - const normals = new WeakMap(); for (let i = 0; i < polygons.length; i ++) { const polygon = polygons[i]; for (let j = 0; j < polygon.length; j ++) { @@ -43,8 +42,6 @@ function createGraph(polygons) { edges.push([point, nextPoint]); nextPoints.set(point, nextPoint); previousPoints.set(point, previousPoint); - - normals.set(point, normal(subtract(nextPoint, point))); } } @@ -68,10 +65,10 @@ function createGraph(polygons) { } } } - return { graph, edges, points, normals }; + return { graph, edges, points }; } -function createNode(graph, points, edges, normals, point) { +function createNode(graph, points, edges, point) { const node = []; const to = graph.length; graph.push(node);