Bug fix for MMTK 1.0b2

Konrad Hinsen hinsen@ibs.ibs.fr
Mon, 30 Jun 1997 11:14:58 +0200

There's a bug in the translation/rotation fit in MMTK that could cause
some bad surprises. For some input geometries, the transformation returned
by object.findTransformation() is *not* the one that results in the
smallest RMS.

To fix this bug, replace the method findTransformation() in class
GroupOfAtoms in module Collection by the following version:

    def findTransformation(self, conf1, conf2 = None):
	import LinearAlgebra
	if conf2 is None:
	    conf1, conf2 = conf2, conf1
	cm1 = self.centerOfMass(conf1)
	cm2 = self.centerOfMass(conf2)
	m = 0.
	k = Numeric.zeros((4,4))
	for a in self.atomList():
	    ma = a._mass
	    r1 = a.position(conf1) - cm1
	    r2 = a.position(conf2) - cm2
	    d = (r1-r2).array
	    w = Tensor.epsilon.dot((r1+r2).asTensor()).array
	    w = Numeric.concatenate((Numeric.reshape(d, (1,3)), w))
	    d = -Numeric.concatenate((Numeric.zeros((1,1), Numeric.Float),
				      Numeric.reshape(d, (3,1))))
	    w = Numeric.concatenate((d, w), -1)
	    k = k + ma*Numeric.dot(Numeric.transpose(w), w)
	    m = m + ma
	k = k/m
	e, v = LinearAlgebra.eigenvectors(k)
	i = Numeric.argmin(e)
	return Transformation.Translation(cm2) * \
	       Quaternion.Quaternion(v[i]).asRotation() * \
	       Transformation.Translation(-cm1), \

For those who don't like messing around with the modules, I have put
a replacement for the file Collection.py on the MMTK Web site

Several people have asked for more examples, specifically about
analysis operations like fits. I'll prepare them in the course of this
week and then send them to this list. If anyone else has interesting
examples, please make them available as well!
Konrad Hinsen                          | E-Mail: hinsen@ibs.ibs.fr
Laboratoire de Dynamique Moleculaire   | Tel.: +33-
Institut de Biologie Structurale       | Fax:  +33-
41, av. des Martyrs                    | Deutsch/Esperanto/English/
38027 Grenoble Cedex 1, France         | Nederlands/Francais