Concave or convex hull around a list of points.
import hull
points = [
(207, 184), (393, 60), (197, 158), (197, 114), (128, 261), (442, 40),
(237, 159), (338, 75), (194, 93), (33, 159), (393, 152), (433, 267),
(324, 141), (384, 183), (273, 165), (250, 257), (423, 198), (227, 68),
(120, 184), (214, 49), (256, 75), (379, 93), (312, 49), (471, 187),
(366, 122)
]
concave_hull = hull.concave(points, 3)
convex_hull = hull.convex(points)
The code above creates the following results:
- pyprocessing if you want to run the visual examples
- The concave hull algorithm is based on a paper by Adriano Moreira and Maribel Yasmina Santos.
- The convex hull algorithm is an implementation of Andrew's monotone chain algorithm.
- Some parts of the concave hull algorithm were copied from Matotempo's Ruby approach.
- The entire convex hull algorithm is copy-pasted from a wikibook about algorithm implementations.