1 回答

TA貢獻1802條經驗 獲得超4個贊
以原點和半徑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 plt
from mpl_toolkits.mplot3d import Axes3D
import math
import numpy as np
L = 50
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
xpoints=[]
ypoints=[]
a = 0.1
b = 0.1
for 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 = 50
h= 0.5
r= 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()
添加回答
舉報