diff --git a/h2/mbc.py b/h2/mbc.py new file mode 100644 index 0000000..d00a1de --- /dev/null +++ b/h2/mbc.py @@ -0,0 +1,21 @@ +import statistics +from collections import namedtuple +from typing import List, Set + +Point = namedtuple('Point', 'x y') + + +def mbc_ch(points: Set[Point]): + # Find the point with median x-coordinate, and partition the points on this point + pm = statistics.median_high(points) + + pl = {point + for point in points + if point.x < pm.x} + + pr = {point + for point in points + if point.x >= pm.x} + + # Find the bridge over the vertical line in pm + \ No newline at end of file diff --git a/h2/sidedness.py b/h2/sidedness.py index 6943214..40ddc25 100644 --- a/h2/sidedness.py +++ b/h2/sidedness.py @@ -55,7 +55,7 @@ def graham_scan(points): # A funky issue where both a and b become negative in the sidedness test causes us to have to use # Side.ABOVE for both tests, regardless of UH or LH. - sorted_points = sorted(points, key=lambda p: p.x) + sorted_points = sorted(points) UH = sorted_points[:2] #del sorted_points[0]