Incrementing area of convex hull

2019-07-11 12:49发布

I want to use convex hull to draw a line around a list of points. However, I would like for the area to be larger than just minimum convex hull. How do I achieve that. P.S. I am using scipy.spatial implementation of ConvexHull, however it finds only the minimum area around list of points.

enter image description here

1条回答
ら.Afraid
2楼-- · 2019-07-11 13:26

Here is an idea to solve the exact problem you have on paper:

from scipy.spatial  import ConvexHull
import matplotlib.pyplot as plt
import numpy as np

if __name__ == '__main__':
    points = np.array([[-2,3], [2,4], [-2,-2], [2,-1], [1,-1], [-0.5, 0.5]])
    plt.scatter(points[:,0], points[:,1])
    plt.show()
    convh = ConvexHull(points)

    stretchCoef = 1.2
    pointsStretched = points[convh.vertices]*stretchCoef
    plt.scatter(points[:,0], points[:,1])
    plt.scatter(pointsStretched[:,0], pointsStretched[:,1], color='r')
    plt.show()

pointsStretched find the new points for your new convex hull. Using a stretching coefficient works here because you have the points on each of the vertices of the convexhull on different quadrants, but I think you get the idea of how to solve this. One way is to find the points in your stretched convexhull, which will be along the same vector as the initial points.

查看更多
登录 后发表回答