def in_euclidean_discance(self, pos, center, r):
"""
A helper function to return true or false.
Decided whether a position(frac) inside a
distance restriction.
"""
from scipy.spatial.distance import euclidean as euclidean_discance
from itertools import product
cart_cent = self.get_cartesian_from_frac(center)
trans = np.array([i for i in product([-1, 0, 1], repeat=3)])
allpos = pos + trans
for p in allpos:
cart_p = self.get_cartesian_from_frac(p)
if euclidean_discance(cart_p, cart_cent) < r:
return True
break
return False
评论列表
文章目录