我有什么?
我有一个凸多边形,看起来像这样:
使用以下代码:
import numpy as np
from scipy.spatial import ConvexHull
import matplotlib.pyplot as plt
# Generate some random points for the demo.
np.random.seed(4321)
pts = 0.1 + 0.8*np.random.rand(15, 2)
ch = ConvexHull(pts)
# Get the indices of the hull points.
hull_indices = ch.vertices
# These are the actual points.
hull_pts = pts[hull_indices, :]
plt.plot(hull_pts[:, 0], hull_pts[:, 1], 'ko', markersize=10)
plt.fill(hull_pts[:, 0], hull_pts[:, 1], fill=False, edgecolor='b')
plt.xlim(0, 1)
plt.ylim(0, 1)
plt.show()
我想要什么?
我可以用scipy.spatial来做吗?怎么做
此代码将值从间隔(0,1)映射到多边形周长,并执行1。(2.考虑到这种解决方案,这是微不足道的):
相关问题 更多 >
编程相关推荐