def is_mirror_image(X, Y):
"""
Check if two configurations X and Y are mirror images
(i.e. their optimal superposition involves a reflection).
@param X: n x 3 input vector
@type X: numpy array
@param Y: n x 3 input vector
@type Y: numpy array
@rtype: bool
"""
from numpy.linalg import det, svd
## center configurations
X = X - numpy.mean(X, 0)
Y = Y - numpy.mean(Y, 0)
## SVD of correlation matrix
V, L, U = svd(numpy.dot(numpy.transpose(X), Y)) #@UnusedVariable
R = numpy.dot(V, U)
return det(R) < 0
评论列表
文章目录