为什么我的代码渲染曲线旋转90度? 我正在尝试制作一个加热电缆的布局以进行地板加热,我遇到了这个问题。 这是我从代码中得到的 所以我做了一个小计划,要求宽度,房间的lenght和

问题描述 投票:0回答:1
我做了一个小计划,要求宽度,房间的lenght并计算为M2。我需要图形表示电缆在地板上的应有图形表示。这是我的拱门代码:

# 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)

我是一个初学者,所以我尝试了到目前为止所知道的。如果有人可以指导我或尽可能地帮助我。
This i what i got from my code

要正确连接曲线与直截面:

调整曲线的方向:在计算
y_curve
时,将其旋转90°,通过使用

theta

的余弦而不是正弦。您可以互换使用这些切换曲线的方向。
python graphics
1个回答
0
投票
(i + 0.5)

(OR + 1.5取决于必要的高度)以动态设置连接部分的高度。

    我使用的代码与所讨论的行调试Y坐标:
  • 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}")
    
    	
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.