3
一個數組,因爲我剛纔的問題是非常不清楚,我編輯它:的Python:計算eucledean距離從一個座標,座標
我有以下問題:
我想構建一個模式一個半徑爲r + fcr_size的萬聖節球。聖球中的空腔應該具有半徑r。有了這種模式,我可以在許多不同的球體中心使用它,並獲得許多神聖的球體。現在我正在尋找最快的解決方案。我的做法是:
centoEdge = radius+fcr_size #Bounding box coordinates from center to edge
xyz_pattern=[]
#Create the Bounding Box only in positive x,y,z direction, because they are later mirrowed
x1 = range(0,int(centoEdge)+1)
y1 = range(0,int(centoEdge)+1)
z1 = range(0,int(centoEdge)+1)
#Check if coordinates are the hallow sphere and add them to xyz_pattern list
for coords in itertools.product(x1,y1,z1):
if radius < distance.euclidean([0,0,0],coords) <= (radius+fcr_size):
xyz_pattern.append(coords)
#mirrow the pattern arround center
out = []
for point in xyz_pattern:
for factors in itertools.product([1, -1], repeat=3): # (1, 1, 1), (1, 1, -1), (1, -1, 1), ..., (-1, -1, -1)
out.append(tuple(point[i]*factors[i] for i in range(3)))
xyz_pattern=list(set(out))
這樣一個球形腔的立方體? –
@ Ev.Kounis:在邊界框中有一個球體空腔的球體 – Varlor
但是邊界框體是球形的嗎?盒子對我來說總是聽起來是矩形的,這就是爲什麼我問... – jotasi