File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ def convex_hull(n, **kwargs):
4444 # fx, fy are functions which map [0,1] to int or float
4545 fx = kwargs .get ("fx" , lambda x : x )
4646 fy = kwargs .get ("fy" , lambda x : x )
47+ strict = kwargs .get ("strict" , True )
4748 sz = n * 2
4849 result = []
4950 while len (result ) < n :
@@ -74,8 +75,9 @@ def convex_hull(n, **kwargs):
7475 a = st [len (st ) - 1 ]
7576 b = points [i ]
7677 o = st [len (st ) - 2 ]
77- if (a [0 ] - o [0 ]) * (b [1 ] - o [1 ]) - \
78- (a [1 ] - o [1 ]) * (b [0 ] - o [0 ]) >= 0 :
78+ tmp = (a [0 ] - o [0 ]) * (b [1 ] - o [1 ]) - \
79+ (a [1 ] - o [1 ]) * (b [0 ] - o [0 ])
80+ if tmp > 0 or (tmp == 0 and not strict ):
7981 break
8082 st .pop ()
8183 st .append (points [i ])
@@ -85,8 +87,9 @@ def convex_hull(n, **kwargs):
8587 a = st [len (st ) - 1 ]
8688 b = points [i ]
8789 o = st [len (st ) - 2 ]
88- if (a [0 ] - o [0 ]) * (b [1 ] - o [1 ]) - \
89- (a [1 ] - o [1 ]) * (b [0 ] - o [0 ]) >= 0 :
90+ tmp = (a [0 ] - o [0 ]) * (b [1 ] - o [1 ]) - \
91+ (a [1 ] - o [1 ]) * (b [0 ] - o [0 ])
92+ if tmp > 0 or (tmp == 0 and not strict ):
9093 break
9194 st .pop ()
9295 st .append (points [i ])
You can’t perform that action at this time.
0 commit comments