0
標記點(註釋稱爲「標記點」)的點是將3D繪圖中的現有點旋轉一個點。基本上我將所有點移動60度。出於某種原因,當移動點時,我有兩點重疊。我試圖改變我的陳述,並且混淆了他的指數,但並未成功。我包括整個功能的唯一原因是,您可以繪製並查看我遇到的問題。這裏是;讓我知道如果您有任何疑問:在xy平面上旋轉點時重疊的繪圖點
def transform_3d_trig(a,b,c):
q=2*math.pi/(360)
d=c*q
a2 = a+b
n = 12
sin=math.sin
cos=math.cos
sqrt=math.sqrt
x = []
y = []
z = []
for i in range(n):
if i <= 5:
x.append(a*np.cos(q*(60*(i-1))))
y.append(a*np.sin(q*(60*(i-1))))
z.append(0)
else:
x.append(a2*np.cos(q*(60*(i-1))))
y.append(a2*np.sin(q*(60*(i-1))))
z.append(0)
x_new = x #new lists
y_new = y
z_new = z
for i in range(n):
y_new[i] = y[i]*cos(d)
z_new[i] = y_new[i]*np.tan(d)
# plot points at this stage (before rotation); no overlapping points
fig = plt.figure(figsize=(12,12))
ax3 = fig.add_subplot(211, projection='3d')
bond2 = [x_new[4],x_new[10],y_new[4],y_new[10],z_new[4],z_new[10]]
ax3.plot(bond2[:2],bond2[2:4],bond2[4:6], color='r')
ax3.scatter(x_new, y_new, z_new)
ax3.set_xlabel('\nX')
ax3.set_ylabel('\nY')
ax3.set_zlabel('\nZ')
x_dummy = x_new #dummy variables to not screw up list
y_dummy = y_new
for i in range(n): #marked spot
if (i == 5 or i == 11):
x_new[i] = x_dummy[i-5]
y_new[i] = y_dummy[i-5]
else:
x_new[i] = x_dummy[i+1]
y_new[i] = y_dummy[i+1]
print(x_new[i], y_new[i]) #to track what point are overlapping
# plot points at this stage (after rotation); overlapping points
ax3 = fig.add_subplot(212, projection='3d')
bond2 = [x_new[4],x_new[10],y_new[4],y_new[10],z_new[4],z_new[10]]
ax3.plot(bond2[:2],bond2[2:4],bond2[4:6], color='r')
ax3.scatter(x_new, y_new, z_new)
ax3.set_xlabel('\nX')
ax3.set_ylabel('\nY')
ax3.set_zlabel('\nZ')
plt.show()
return x, y, z, x_new, y_new, z_new
對不起,我的評論在混亂製成。 x_new,y_new和z_new是列表,而不是數組。我又壞了。我將編輯我的原始帖子。 –
只是一樣。您複製引用,而不是複製內容。 – Julien
它給了我一個錯誤「'列表'對象沒有屬性'複製'」 –