[英]How do I plot a cylinder which is similar to toilet paper .Rotating archimedeian spiral forming a cylinder
我知道如何獲得圓柱體,但我想描繪一些類似衛生紙卷的圖形,該圖形在圓柱體表面上繪制了阿基米德螺旋線。
但是我需要的是衛生紙卷,就像情節一樣。
我想出了這背后的數學原理,有人可以幫助我使用python,我需要針對以下方程式以3D形式繪制它:在實踐中,公式
我想用L作為參數,我的方程就變成了
h是金屬厚度,r是軋輥的內半徑。 該公式使用螺旋輥的圓近似值。 我也知道長度L = 50有人可以用matplotlib代碼幫助我
這正是我所需要的http://pgfplots.net/tikz/examples/cylinder-spiral/請查看此鏈接
以下是解決方案我以某種方式弄清楚如果有人幫助我改進我的解決方案,我會很高興
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()
以原點和半徑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圖形,可以在linspace(0, L)
中添加z
,其中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()
由於您有一個工作代碼,您可以將其發布在代碼審查堆棧交換中,我可以使用排版數學進行解釋。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.