From 12e782b3f32a6ce50d5eac7369220f43e71e899c Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Sun, 24 May 2020 13:26:37 -0400 Subject: [PATCH] Update JavaScript Jarvis March to use points from Graham Scan --- .../code/javascript/jarvis-march.js | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/contents/jarvis_march/code/javascript/jarvis-march.js b/contents/jarvis_march/code/javascript/jarvis-march.js index 2b0f36e46..97806a0da 100644 --- a/contents/jarvis_march/code/javascript/jarvis-march.js +++ b/contents/jarvis_march/code/javascript/jarvis-march.js @@ -24,16 +24,22 @@ function isLeftOf({ a, b }, p) { } const points = [ - { x: 1, y: 3 }, - { x: 2, y: 4 }, - { x: 4, y: 0 }, - { x: 1, y: 0 }, - { x: 0, y: 2 }, - { x: 2, y: 2 }, - { x: 3, y: 4 }, - { x: 3, y: 1 }, + { x: -5, y: 2 }, + { x: 5, y: 7 }, + { x: -6, y: -12 }, + { x: -14, y: -14 }, + { x: 9, y: 9 }, + { x: -1, y: -1 }, + { x: -10, y: 11 }, + { x: -6, y: 15 }, + { x: -6, y: -8 }, + { x: 15, y: -9 }, + { x: 7, y: -7 }, + { x: -2, y: -9 }, + { x: 6, y: -5 }, + { x: 0, y: 14 }, + { x: 2, y: 8 } ]; const convexHull = jarvisMarch(points); convexHull.forEach(p => console.log(`(${p.x}, ${p.y})`)); -