慕虎7371278
以原点和半径r为圆心的圆的参数方程为, x = r \times sin(\theta) y = r \times cos(\theta) 其中\theta \in [0,2\pi]。对于螺旋,半径随着 \$\theta\$ 增加。假设 \$r\$ 依赖,\theta因为r = (a+b\theta)它可以, x = (a+b\theta) sin(\theta) y = (a+b\theta) cos(\theta)要使其成为具有垂直轴的 3D 图形,您可以添加圆柱体的长度z在linspace(0, L)哪里L。import matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dimport mathimport numpy as npL = 50fig = plt.figure()ax = fig.add_subplot(111, projection='3d')xpoints=[]ypoints=[]a = 0.1b = 0.1for theta in np.linspace(0, 2*math.pi, 20): xpoints.append((a+b*theta)*math.cos(theta)) ypoints.append((a+b*theta)*theta*math.sin(theta)) z = np.linspace(0,L) theta, z = np.meshgrid(theta, z)ax.plot_surface(xpoints,ypoints,z)plt.show()既然你有一个工作代码,你可以把它发布在代码审查堆栈交换中,我可以在那里用排版数学来解释。以下是我以某种方式想出的解决方案,如果有人帮助我改进我的解决方案,我会很高兴L = 50h= 0.5r= 5.0[![plot][1]][1]R = np.sqrt((L*h)/(np.pi)+r**r)fig = plt.figure()ax = fig.add_subplot(111, projection='3d')xpoints=[]ypoints=[]for theta in np.linspace(0,20,R): xpoints.append(1.1*theta*cos(theta)) ypoints.append(1.1*theta*sin(theta)) z = np.linspace(0,R) theta, z = np.meshgrid(t, z)ax.plot_surface(xpoints,ypoints,z)plt.show()