From 1f6ade0c9a62eeabc644187213789ced41e4e306 Mon Sep 17 00:00:00 2001 From: Alexander Munch-Hansen Date: Thu, 20 Sep 2018 16:05:08 +0200 Subject: [PATCH] Upper hull --- h2/quick_hull.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/h2/quick_hull.py b/h2/quick_hull.py index 7621a7f..b1b39a1 100644 --- a/h2/quick_hull.py +++ b/h2/quick_hull.py @@ -61,16 +61,11 @@ def quick_hull(points: Set[Point]): hull = {left, right} points = points - hull - find_hull({p for p in points if not is_left(left, right, p)}, + find_hull({p for p in points if is_left(left, right, p)}, left, right, hull) - find_hull({p for p in points if not is_left(right, left, p)}, - right, - left, - hull) - return hull @@ -83,20 +78,24 @@ def find_hull(points: Set[Point], p: Point, q: Point, hull: Set[Point]): s1 = {point for point in points - if not is_left(p, farthest, point)} + if is_left(p, farthest, point)} print("--") print(s1) s2 = {point for point in points - if not is_left(farthest, q, point)} + if is_left(farthest, q, point)} print(s2) find_hull(s1, p, farthest, hull) find_hull(s2, farthest, q, hull) -peepees = {gen_point() for _ in range(11)} +peepees = {gen_point() for _ in range(13)} +#peepees = {Point(2, 5), Point(3, 1), Point(3, 4), Point(9, 4), Point(1, 5), Point(5, 7)} + hulliees = quick_hull(peepees) -display(peepees, hulliees) +a = sorted(hulliees) + +display(peepees, a)