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