Perimeter of a 2D convex hull in Python
问题 How can I calculate the perimeter of a convex hull in Python? I know SciPy has the area parameter for convex hulls; however, I need the perimeter . 回答1: You can iterate over the points of the convex hull and compute the distance between consecutive points: import numpy as np from scipy.spatial.qhull import ConvexHull from scipy.spatial.distance import euclidean points = np.random.rand(30, 2) hull = ConvexHull(points) vertices = hull.vertices.tolist() + [hull.vertices[0]] perimeter = np.sum(