Python 我如何画一个类似厕纸的圆柱体。旋转阿基米德螺线形成圆柱体

Python 我如何画一个类似厕纸的圆柱体。旋转阿基米德螺线形成圆柱体,python,matplotlib,Python,Matplotlib,我知道如何得到一个圆柱体,但我想用圆柱体在表面描绘一些像卫生纸卷的东西 但我需要的是像情节一样的卫生纸卷 我算出了这背后的数学,有人能帮我用python吗?我需要用3D绘制它,得到以下等式 实际上,这个公式 我想用L作为参数,我的方程变成 这里h是金属厚度,r是轧辊的内径。该公式使用螺旋辊的圆形近似。我也知道长度L=50有人能帮我处理matplotlib代码吗 这正是我需要的 请看这个链接 有人能帮我把它放到Matplotlib中吗?下面是解决方案,我不知怎么弄明白了,如果有人帮我改进我的解

我知道如何得到一个圆柱体,但我想用圆柱体在表面描绘一些像卫生纸卷的东西

但我需要的是像情节一样的卫生纸卷

我算出了这背后的数学,有人能帮我用python吗?我需要用3D绘制它,得到以下等式 实际上,这个公式

我想用L作为参数,我的方程变成

这里h是金属厚度,r是轧辊的内径。该公式使用螺旋辊的圆形近似。我也知道长度L=50有人能帮我处理matplotlib代码吗

这正是我需要的 请看这个链接

有人能帮我把它放到Matplotlib中吗?下面是解决方案,我不知怎么弄明白了,如果有人帮我改进我的解决方案,我会很高兴的

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

以原点和半径为中心的圆的参数方程为,
x=r\times sin(\theta)
y=r\times cos(\theta)
其中,
\theta\in[0,2\pi]

对于缓和曲线,半径随\$\θ\$增加。假设\$r\$依赖于
\theta
作为
r=(a+b\theta)
它可以是,
x=(a+b\theta)sin(\theta)
y=(a+b\theta)cos(\theta)

要使其成为具有垂直轴的三维图形,可以在
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()

由于您有一个工作代码,您可以将其发布在代码复查堆栈交换中,我可以用排版数学进行解释。

您可以查看图像中的螺旋圆柱体,我需要使用matplotlib绘制相同的内容,您可以将其视为卫生纸卷