怎样画一个类似厕纸的圆柱体。旋转阿基米德螺线形成圆柱体

2024-10-17 06:15:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我知道如何得到一个圆筒,但我想描绘的东西像卫生纸卷在表面与圆筒螺旋。你知道吗

How to parameterize a curved cylinder?

但我需要的是像情节一样的卫生纸卷。你知道吗

我发现了这个背后的数学,有人能帮我用python吗?我需要用3D来绘制它,如下等式 实际上,公式

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

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

这正是我需要的 http://pgfplots.net/tikz/examples/cylinder-spiral/请看这个链接

有人能帮我把它放到MatplotlibCylindrical spiral


Tags: to参数绘制数学表面how公式parameterize
2条回答

以原点和半径为中心的圆的参数方程是, 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()

既然你有一个工作代码,你可以把它放在代码复查堆栈交换中,我可以用排版数学解释。你知道吗

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

相关问题 更多 >