From 93c58d1a27e8e32d4a4c2a3fa62e7f4cbdfb7cdd Mon Sep 17 00:00:00 2001 From: Eric Berquist Date: Sun, 24 May 2020 13:29:00 -0400 Subject: [PATCH] Update C Jarvis March to use points from Graham Scan --- contents/jarvis_march/code/c/jarvis_march.c | 23 +++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/contents/jarvis_march/code/c/jarvis_march.c b/contents/jarvis_march/code/c/jarvis_march.c index 5344aa512..f662aaf0e 100644 --- a/contents/jarvis_march/code/c/jarvis_march.c +++ b/contents/jarvis_march/code/c/jarvis_march.c @@ -55,11 +55,26 @@ size_t jarvis_march(struct point *points, struct point *hull_points, } int main() { - struct point points[] = {{0.0, 0.0}, {-1.0, -1.0}, {1.0, 1.0}, {0.0, 1.0}, - {0.0, -1.0}, {2.0, 2.0}}; - struct point hull_points[6]; + struct point points[] = { + { -5.0, 2.0 }, + { 5.0, 7.0 }, + { -6.0, -12.0 }, + { -14.0, -14.0 }, + { 9.0, 9.0 }, + { -1.0, -1.0 }, + { -10.0, 11.0 }, + { -6.0, 15.0 }, + { -6.0, -8.0 }, + { 15.0, -9.0 }, + { 7.0, -7.0 }, + { -2.0, -9.0 }, + { 6.0, -5.0 }, + { 0.0, 14.0 }, + { 2.0, 8.0 } + }; + struct point hull_points[15]; - size_t num_hull_points = jarvis_march(points, hull_points, 6); + size_t num_hull_points = jarvis_march(points, hull_points, 15); printf("The Hull points are:\n"); for (size_t i = 0; i < num_hull_points; ++i) {