生成弯曲的多边形

时间:2020-05-04 21:10:24

标签: python math polygon spline

如何向多边形的顶点和边缘添加曲率。

我正在尝试创建一些弯曲的多边形,例如curved verticescurved edge shapeseven both

您将如何生成这些形状。 我研究了Bezier曲线,但是它们似乎很复杂,我想在提交此方法之前先知道是否有任何更简单的解决方案。

这是我的代码,用于在任何需要起点的情况下生成多边形。

def gen_poly(sides, radius=1, rotation=0):
    seg = math.pi * 2 / sides
    x_list = []
    y_list = []
    for i in range(sides): 
        x = math.sin(seg * i + rotation) * radius
        y = math.cos(seg * i + rotation) * radius
        x_list.append(x)
        y_list.append(y)
    x_list.append(x_list[0])
    y_list.append(y_list[0]) 
    return x_list,y_list
x,y=polygon(5) 

fig = plt.figure()
ax = plt.subplot(111)
ax.plot(x, y, marker='.')
plt.xlabel('x')
plt.ylabel('y')
plt.show()

0 个答案:

没有答案