def translateAlongAxis(cords, axis, distance): new_cords = cords.copy() _axis = vector.getUnitVec(axis) translation_vector = [0, 0, 0] translation_vector[0] = distance * _axis[0] translation_vector[1] = distance * _axis[1] translation_vector[2] = distance * _axis[2] new_cords['x'] = new_cords['x'] + translation_vector[0] new_cords['y'] = new_cords['y'] + translation_vector[1] new_cords['z'] = new_cords['z'] + translation_vector[2] return new_cords
def getRotMat(axis, theta): R = np.zeros((3, 3)) s = vector.getUnitVec(axis) t = theta vv = (1 - cos(t)) R[0][0] = s[0] * s[0] * vv + cos(t) R[0][1] = s[0] * s[1] * vv - s[2] * sin(t) R[0][2] = s[0] * s[2] * vv + s[1] * sin(t) R[1][0] = s[0] * s[1] * vv + s[2] * sin(t) R[1][1] = s[1] * s[1] * vv + cos(t) R[1][2] = s[1] * s[2] * vv - s[0] * sin(t) R[2][0] = s[0] * s[2] * vv - s[1] * sin(t) R[2][1] = s[1] * s[2] * vv + s[0] * sin(t) R[2][2] = s[2] * s[2] * vv + cos(t) return R
def getNearestAtomList(df,point,direction,distance): atom_list=[] direction=vector.getUnitVec(direction) for index,row in df.iterrows(): p=[0,0,0] atom_cords=row[['x','y','z']].values p[0]=atom_cords[0]-point[0] p[1]=atom_cords[1]-point[1] p[2]=atom_cords[2]-point[2] projection=vector.getDotProduct(direction,p) if isZero(p): continue if np.abs(round(projection,6))<=distance: atom_list.append(row['atom_no']) return atom_list
def getRPYAngles(v1,v2,axis='x',unit='radians'): rpy=np.zeros(3) s=vector.getCrossProduct(v1,v2) s=vector.getUnitVec(s) theta=vector.getAngleR(v1,v2) R=getRotMat(s,theta) if axis=='x': rpy[1]=asin(fixArcDomain(-1*R[2][0])) rpy[0]=asin(fixArcDomain(R[2][1]/cos(rpy[1]))) rpy[2]=asin(fixArcDomain(R[1][0]/cos(rpy[1]))) elif axis=='y': rpy[2]=asin(-1*R[0][1]) rpy[1]=asin(R[0][2]/cos(rpy[2])) rpy[0]=asin(R[2][1]/cos(rpy[2])) elif axis=='z': rpy[0]=asin(-1*R[1][2]) rpy[1]=asin(R[0][2]/cos(rpy[0])) rpy[2]=asin(R[1][0]/cos(rpy[0])) else: print('To be implemented') if unit=='radians': return rpy elif unit=='degrees': return list(map(math.degrees,rpy))
def getAtomicDisplacement(v1, v2): mag1 = vector.getMag(v1) mag2 = vector.getMag(v2) trans_vec = (mag2 - mag1) * vector.getUnitVec(v2) return trans_vec