我已經在3D平面上完成了一個點過濾程序,但是我需要沿已知長度的已知3D法向矢量進行循環。非常感謝您的幫助。如何沿着已知長度的3D矢量進行循環python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
point = sta[10] #starting points
normal = axe[10] #normal vector
d = -point.dot(normal)
# create x,y
xx, yy = np.meshgrid(np.linspace(-3.,-2.,101), np.linspace(-11.,-10.,101))
# calculate corresponding z
z = (-normal[0] * xx - normal[1] * yy - d) * 1. /normal[2]
f=[]
for i in xrange(len(xx)-1):
for j in xrange(len(xx)-1):
if (xx[i][j]-sta[10][0])**2 + (yy[i][j]-sta[10][1])**2 + (z[i][j]-sta[10][2])**2 > float(rad[0])**2:
xx[i][j]=NaN
yy[i][j]=NaN
z[i][j]=NaN
什麼是「STA」和「斧頭」?你已經在開始時將numpy定義爲np,然後在代碼中使用'numpy'。 –
正如我所說的,sta是一個包含起始3D點的數組,是一個圓的中心。 Ax是包含法向量的數組。 –
您是否曾經兩次使用len(xx)?直覺上,我會建議使用len(yy)和len(xx) – Moritz