Skip to content

Commit ff494db

Browse files
authored
Update JavaScript Jarvis March to use points from Graham Scan (#708)
1 parent d127a81 commit ff494db

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

contents/jarvis_march/code/javascript/jarvis-march.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,22 @@ function isLeftOf({ a, b }, p) {
2424
}
2525

2626
const points = [
27-
{ x: 1, y: 3 },
28-
{ x: 2, y: 4 },
29-
{ x: 4, y: 0 },
30-
{ x: 1, y: 0 },
31-
{ x: 0, y: 2 },
32-
{ x: 2, y: 2 },
33-
{ x: 3, y: 4 },
34-
{ x: 3, y: 1 },
27+
{ x: -5, y: 2 },
28+
{ x: 5, y: 7 },
29+
{ x: -6, y: -12 },
30+
{ x: -14, y: -14 },
31+
{ x: 9, y: 9 },
32+
{ x: -1, y: -1 },
33+
{ x: -10, y: 11 },
34+
{ x: -6, y: 15 },
35+
{ x: -6, y: -8 },
36+
{ x: 15, y: -9 },
37+
{ x: 7, y: -7 },
38+
{ x: -2, y: -9 },
39+
{ x: 6, y: -5 },
40+
{ x: 0, y: 14 },
41+
{ x: 2, y: 8 }
3542
];
3643

3744
const convexHull = jarvisMarch(points);
3845
convexHull.forEach(p => console.log(`(${p.x}, ${p.y})`));
39-

0 commit comments

Comments
 (0)