def normal_vector(self, xyz):
xyz = xyz.reshape(-1,3)
a = np.array(self.a)
b = self.b
c = np.array(self.c)
xyza = np.mean(xyz[a], axis=0)
xyzc = np.mean(xyz[c], axis=0)
# vector from first atom to central atom
vector1 = xyza - xyz[b]
# vector from last atom to central atom
vector2 = xyzc - xyz[b]
# norm of the two vectors
norm1 = np.sqrt(np.sum(vector1**2))
norm2 = np.sqrt(np.sum(vector2**2))
crs = np.cross(vector1, vector2)
crs /= np.linalg.norm(crs)
return crs
评论列表
文章目录