1
#vector
vec=[(.033,-.22,.98),(.5,-.9,.0029),(-.77,-.01,-.092),(.5,.2,.0029)]
#grid
x1 = np.linspace(-1,1,10)
y1 = np.linspace(-1,1,10)
z1 = np.linspace(-1,1,10)
林這段代碼,這顯然是錯誤的,因爲它這需要在3D網格要檢查上谷三維坐標的向量座標只是比較第一x座標,而不是y的其餘,Z
ctr=0
for v in vec:
for i in x1:
for j in y1:
for k in z1:
if ctr==0:
temp=(i,j,k)
ctr+=1
continue
else:
#print temp, "to" ,i,j
temp2=(i,j,k)
if temp<=v<=temp2:
print "low,high",temp, temp2
temp=(i,j,k)
ctr+=1
===WRONG OUTPUT======
low,high (-0.052631578947368474, 1.0, 1.0) (0.052631578947368363, -1.0, -1.0)
low,high (0.47368421052631571, 1.0, 1.0) (0.57894736842105265, -1.0, -1.0)
low,high (-0.78947368421052633, 1.0, 1.0) (-0.68421052631578949, -1.0, -1.0)
low,high (0.47368421052631571, 1.0, 1.0) (0.57894736842105265, -1.0, -1.0)
伊夫粘貼二維網格這裏(3D將遵循相同的邏輯)。所以我們開始以連續順序從單元格(0,0)迭代網格。正如你所看到的較低&更高的座標點v
你能更清楚地確定你的上限值是什麼意思?起源距離? 2個座標之間的最大距離是多少? –
@jeffcarey添加了描述圖片 – vinita