Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Raoul Bock committed Dec 15, 2023
1 parent 1198f42 commit 5509be5
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions js/math/graph.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@ class Graph {
}

static load(info) {
const points = [];
const segments = [];
const points = info.points.map((i) => new Point(i.x, i.y));
const segments = info.segments.map(
(i) =>
new Segment(
points.find((p) => p.equals(i.p1)),
points.find((p) => p.equals(i.p2))
)
);

for (const pointInfo of info.points) {
points.push(new Point(pointInfo.x, pointInfo.y));
}

for (const segInfo of info.segments) {
segments.push(new Segment(segInfo.p1, segInfo.p2));
}
return new Graph(points, segments);
}

Expand Down

0 comments on commit 5509be5

Please sign in to comment.