Skip to content

Commit 65e069f

Browse files
committed
Changing back to the standard
1 parent a6f6d9e commit 65e069f

File tree

1 file changed

+3
-4
lines changed
  • chapters/computational_geometry/gift_wrapping/graham_scan/code/c

1 file changed

+3
-4
lines changed

chapters/computational_geometry/gift_wrapping/graham_scan/code/c/graham.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <math.h>
2-
#include <stdbool.h>
32
#include <stddef.h>
43
#include <stdio.h>
54
#include <stdlib.h>
@@ -22,8 +21,8 @@ int cmp_points(const void *a, const void *b) {
2221
}
2322
}
2423

25-
bool is_left_of(struct point a, struct point b, struct point c) {
26-
return (b.x - a.x) * (c.y - a.y) < (b.y - a.y) * (c.x - a.x);
24+
double ccw(struct point a, struct point b, struct point c) {
25+
return (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
2726
}
2827

2928
double polar_angle(struct point origin, struct point p) {
@@ -73,7 +72,7 @@ size_t graham_scan(struct point *points, size_t size) {
7372

7473
size_t m = 1;
7574
for (size_t i = 2; i <= size; ++i) {
76-
while (is_left_of(tmp_points[m - 1], tmp_points[m], tmp_points[i])) {
75+
while (ccw(tmp_points[m - 1], tmp_points[m], tmp_points[i]) <= 0) {
7776
if (m > 1) {
7877
m--;
7978
continue;

0 commit comments

Comments
 (0)