1

How do i add curvature to the vertices and edges of polygons.

I'm trying to create some curved polygons such as these curved vertices, curved edge shapes or even both

How would you go generating these shapes. I've looked into Bezier curves but they seem quite involving, I want to know if there are any simpler solution before I commit to this method.

Here's my code for generating polygons if anyone needs a starting point.

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()
RobotBarry
  • 73
  • 2
  • 11
  • A [polygon](https://en.wikipedia.org/wiki/Polygon) "...is a plane figure that is described by a finite number of **straight line segments** connected to form a closed polygonal chain". – martineau May 04 '20 at 21:26
  • 1
    You don't have to manually code bézier curves (although there are plenty options for that), [matplotlib got them covered](https://matplotlib.org/3.2.1/gallery/shapes_and_collections/quad_bezier.html). – Jongware May 04 '20 at 22:12
  • 1
    You could take a look at [Chaikin's Corner Cutting Algorithm](https://observablehq.com/@pamacha/chaikins-algorithm). Here's a discussion on [Python](https://stackoverflow.com/questions/47068504/where-to-find-python-implementation-of-chaikins-corner-cutting-algorithm) implementations. – RaffleBuffle May 05 '20 at 03:15
  • @SirRaffleBuffle Exactly what I'm after, thanks! If you know of any other algorithms for generating any type of continues polygons such as [reuleaux shapes](https://mathworld.wolfram.com/ReuleauxPolygon.html) or [CST (page 15-16](http://www.brendakulfan.com/docs/CST3.pdf), please let me know. I'm trying to build a large set of varied polygons. – RobotBarry May 05 '20 at 03:23

0 Answers0