使用下面的代码,我正在尝试对一个用罐头制成的碗进行建模。我希望每个标记都是一个罐子,最好的方法是什么?
我真的很感激任何建议,谢谢。
import pylab
import numpy as np
from math import pi, sin, cos
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
numCansHigh = 24
startCanNum = 15
hCan = 41
dCan = 85
rCan = dCan/2.0
# Rise options: 0,1,2,3
baseRise = 3
topRise = 2
changeH = 8
z = np.linspace(0, hCan*numCansHigh, num=numCansHigh)
n=[startCanNum]
for i in range(1, changeH):
n.append(n[i-1] + baseRise)
for i in range(changeH,len(z)):
n.append(n[i-1] + topRise)
r = [i*rCan/(pi) for i in n]
theta = [2*pi / a for a in n]
totalCans = 0
for i in range(len(z)):
for j in range(int(n[i])):
totalCans+=1
x9 = r[i]*cos(j*theta[i])
y9 = r[i]*sin(j*theta[i])
z9 = z[i]
ax.scatter(x9,y9,z9,s=500,marker='s')
plt.show()