Skip to content

Commit 9ac39ef

Browse files
authored
Merge pull request #707 from berquist/jarvis-march-c-points
Update C Jarvis March to use points from Graham Scan
2 parents a7a8dfb + 93c58d1 commit 9ac39ef

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

contents/jarvis_march/code/c/jarvis_march.c

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,26 @@ size_t jarvis_march(struct point *points, struct point *hull_points,
5555
}
5656

5757
int main() {
58-
struct point points[] = {{0.0, 0.0}, {-1.0, -1.0}, {1.0, 1.0}, {0.0, 1.0},
59-
{0.0, -1.0}, {2.0, 2.0}};
60-
struct point hull_points[6];
58+
struct point points[] = {
59+
{ -5.0, 2.0 },
60+
{ 5.0, 7.0 },
61+
{ -6.0, -12.0 },
62+
{ -14.0, -14.0 },
63+
{ 9.0, 9.0 },
64+
{ -1.0, -1.0 },
65+
{ -10.0, 11.0 },
66+
{ -6.0, 15.0 },
67+
{ -6.0, -8.0 },
68+
{ 15.0, -9.0 },
69+
{ 7.0, -7.0 },
70+
{ -2.0, -9.0 },
71+
{ 6.0, -5.0 },
72+
{ 0.0, 14.0 },
73+
{ 2.0, 8.0 }
74+
};
75+
struct point hull_points[15];
6176

62-
size_t num_hull_points = jarvis_march(points, hull_points, 6);
77+
size_t num_hull_points = jarvis_march(points, hull_points, 15);
6378

6479
printf("The Hull points are:\n");
6580
for (size_t i = 0; i < num_hull_points; ++i) {

0 commit comments

Comments
 (0)