This commit is contained in:
Casper 2018-09-24 15:27:08 +02:00
parent 782fefdb06
commit a3a97f9c00
2 changed files with 22 additions and 1 deletions

21
h2/mbc.py Normal file
View File

@ -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

View File

@ -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]