简体   繁体   中英

How do I plot a cylinder which is similar to toilet paper .Rotating archimedeian spiral forming a cylinder

I know how to get a cylinder but I want to depict something like toilet paper roll plotting archimedian spiral at the surface with the cylinder.

How to parameterize a curved cylinder?

But what I need is Toilet paper roll like the plot.

I figured out the math behind this can someone help me with python I need to plot it in 3D for the following equation In practice the formula

I want to use L as parameter and my equation becomes

Here h is metal thickness, r is inner radius of the roll. This formula is using circular approximation of the spiral roll. I also know length L =50 Can someone help me with matplotlib code

This is exactly what I need http://pgfplots.net/tikz/examples/cylinder-spiral/ please look at this link

Can someone help me to put it in Matplotlib 圆柱螺旋

气缸螺旋 Below is the solution I somehow figured it out I would be happy if someone help me to better my solution

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

The parametric equation for a circle centered on the origin and radius r is, x = r \\times sin(\\theta) y = r \\times cos(\\theta) where \\theta \\in [0,2\\pi] .

For a spiral, the radius increases with \\$\\theta\\$. Assuming that \\$r\\$ relies on \\theta as r = (a+b\\theta) it can be, x = (a+b\\theta) sin(\\theta) y = (a+b\\theta) cos(\\theta)

For it to be a 3D figure with a vertical axis, you can add z in linspace(0, L) where L is the length of the cylinder.

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

Since you have a working code, you can post it in Code review Stack Exchange where I can explain with typeset math.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM