1 回答

TA貢獻(xiàn)1802條經(jīng)驗(yàn) 獲得超4個(gè)贊
以原點(diǎn)和半徑r為圓心的圓的參數(shù)方程為, x = r \times sin(\theta) y = r \times cos(\theta) 其中\(zhòng)theta \in [0,2\pi]。
對于螺旋,半徑隨著 \$\theta\$ 增加。假設(shè) \$r\$ 依賴,\theta因?yàn)閞 = (a+b\theta)它可以, x = (a+b\theta) sin(\theta) y = (a+b\theta) cos(\theta)
要使其成為具有垂直軸的 3D 圖形,您可以添加圓柱體的長度z在linspace(0, L)哪里L(fēng)。
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()
既然你有一個(gè)工作代碼,你可以把它發(fā)布在代碼審查堆棧交換中,我可以在那里用排版數(shù)學(xué)來解釋。
以下是我以某種方式想出的解決方案,如果有人幫助我改進(jìn)我的解決方案,我會(huì)很高興
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()
添加回答
舉報(bào)