# Add C-shaped curves at the end of each section
for i in range(int(width // spacing)):
theta = np.linspace(0, np.pi, 100)
x_curve = length + (spacing / 2) * np.cos(theta)
y_curve = (i + 1) * spacing + (spacing / 2) * np.sin(theta)
color = 'blue' if total_length < 5 else 'red'
ax.plot(x_curve, y_curve, color=color)
total_length += np.pi * (spacing / 2)
我是一个初学者,所以我尝试了到目前为止所知道的。如果有人可以指导我或尽可能地帮助我。
调整曲线的方向:在计算
y_curve
时,将其旋转90°,通过使用theta
(i + 0.5)
(OR + 1.5取决于必要的高度)以动态设置连接部分的高度。
width = 10
spacing = 1
length = 10
for i in range(int(width // spacing)):
theta = np.linspace(0, np.pi, 100)
x_curve = length + (spacing / 2) * np.cos(theta)
y_curve = (i + 0.5) * spacing + (spacing / 2) * np.cos(theta) # this is the line in qquestion
print(f"X: {x_curve}\nY: {y_curve}")