# [MMTK] principal axes

**Konrad Hinsen
**
hinsen@cnrs-orleans.fr

*30 Sep 2001 12:36:56 +0200*

"Jochen Küpper" <jochen@jochen-kuepper.de> writes:
>* As I see it I have move all atoms of the GA to new positions so the
*>* implicit axis system is the PAS. As MMTK doesn't provide a method to
*>* do that directly, I am thinking of the following algorithm:
*
Doesn't the method normalizeConfiguration() do exactly what you need?
>* - get COM and inertial tensor of GA (MMTK), diagonalize tensor (NumPy)
*>* - get atomList() of GA (MMTK)
*>* - translate and rotate every atom to its PAS position
*>* - setPosition() for atoms (MMTK)
*
That's indeed what it does, here is the code:
def normalizeConfiguration(self):
"""Applies a linear transformation such that the coordinate
origin becomes the center of mass of the object and its
principal axes of inertia are parallel to the three coordinate
axes."""
from LinearAlgebra import determinant
cm, inertia = self.centerAndMomentOfInertia()
self.translateBy(-cm)
ev, diag = inertia.diagonalization()
if determinant(diag.array) < 0:
diag.array[0] = -diag.array[0]
self.applyTransformation(Transformation.Rotation(diag))
>* Is this usage of atomList() + setPosition() ok? Are there any obvious
*>* problems I am overseeing?
*
You can do it this way, but it is better to the geometrical operations
provided for groups of atoms, i.e. translateBy(),
rotateAroundCenter(), etc. The advantage is that they can be
optimized. For example, when used on a whole universe, these
operations are much faster than for other objects, because they use
direct operations on the configuration variable rather than iteratin
over the atom list.
Konrad.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen@cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------