Skip to content

Commit a3dada2

Browse files
authored
More pep8
1 parent 5fa8fec commit a3dada2

File tree

1 file changed

+12
-12
lines changed
  • chapters/computational_geometry/gift_wrapping/graham_scan/code/python

1 file changed

+12
-12
lines changed

chapters/computational_geometry/gift_wrapping/graham_scan/code/python/grahamScan.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22

33

44
#Is the turn counter clockwise?
5-
def counter_Clockwise(p1, p2, p3):
5+
def counter_clockwise(p1, p2, p3):
66
return (p3[1]-p1[1])*(p2[0]-p1[0]) >= (p2[1]-p1[1])*(p3[0]-p1[0])
77

88

99
#Find the polar angle of a point relative to a reference point
10-
def polar_Angle(ref, point):
10+
def polar_angle(ref, point):
1111
return atan2(point[1]-ref[1],point[0]-ref[0])
1212

1313

14-
def graham_Scan(gift):
15-
start = min(gift, key=lambda p: (p[1],p[0])) #Must be in hull
14+
def graham_scan(gift):
15+
start = min(gift, key=lambda p: (p[1], p[0])) #Must be in hull
1616
gift.remove(start)
1717

18-
S = sorted(gift,key=lambda point: polar_Angle(start,point))
19-
hull = [start,S[0],S[1]]
18+
s = sorted(gift,key=lambda point: polar_angle(start, point))
19+
hull = [start,s[0],s[1]]
2020

2121
#Remove points from hull that make the hull concave
22-
for pt in S[2:]:
23-
while not counter_Clockwise(hull[-2],hull[-1],pt):
22+
for pt in s[2:]:
23+
while not counter_clockwise(hull[-2], hull[-1], pt):
2424
del hull[-1]
2525
hull.append(pt)
2626

2727
return hull
2828

2929

3030
def main():
31-
test_Gift = [(-5,2),(5,7),(-6,-12),(-14,-14),(9,9),
32-
(-1,-1),(-10,11),(-6,15),(-6,-8),(15,-9),
33-
(7,-7),(-2,-9),(6,-5),(0,14),(2,8)]
34-
hull = graham_Scan(test_Gift)
31+
test_gift = [(-5, 2), (5, 7), (-6, -12), (-14, -14), (9, 9),
32+
(-1, -1), (-10, 11), (-6, 15), (-6, -8), (15, -9),
33+
(7, -7), (-2, -9), (6, -5), (0, 14), (2, 8)]
34+
hull = graham_scan(test_gift)
3535

3636
print("The points in the hull are:")
3737
for point in hull:

0 commit comments

Comments
 (0)