Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion axi/paths.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
from math import hypot
from pyhull.convex_hull import ConvexHull
from shapely import geometry

from .spatial import Index

try:
from pyhull.convex_hull import ConvexHull
except ImportError:
ConvexHull = None

def load_paths(filename):
paths = []
with open(filename) as fp:
Expand Down Expand Up @@ -121,6 +125,9 @@ def crop_paths(paths, x1, y1, x2, y2):
return result

def convex_hull(points):
if ConvexHull is None:
raise Exception('path.convex_hull() requires pyhull')

hull = ConvexHull(points)
vertices = set(i for v in hull.vertices for i in v)
return [hull.points[i] for i in vertices]
Expand Down