# [Chimera-users] Re: chimera questions

Thomas Goddard goddard at cgl.ucsf.edu
Fri Jun 11 09:36:32 PDT 2004

```Hi Wen,

There is not a Chimera command to print the transformation of one model
relative to another.  But you can get it with some Python code.  Below
is some Python code to add two keyboard shortcuts that print the transform
of model 0 relative to model 1 or model 1 relative to model 0.  The model
numbers are shown in the Model Panel dialog (Tools/Inspectors or Favorites
menu), 0 being the first model you opened.

To use the keyboard shortcuts copy the Python code below to a file,
say accel.py.  Show the accelerator dialog, Tools/Keyboard/Accelerator List,
and enter the path to the accelerator file and press Load.  Also click
the "Accelerators on" switch.  After loading two models you can type x0 or
x1 in the Chimera graphics window and it will print out the transform to
remembered so you only need to do this setup once.  To have the accelerators
be on whenever you start Chimera, set Accelerators On to "auto start" in
Favorites/Preferences/Category Tools.

The transformation matrix is a 3 by 4 matrix.  The first 3 columns give
the rotation, and the 4th column is a translation.  The rotation is applied
first, then the translation.

Tom

def print_transform(model_id_1, model_id_2):
'''Print transformation matrix of model 1 relative to model 2.'''
import chimera
m1 = chimera.openModels.list(id = model_id_1)[0]      # returns a list
m2 = chimera.openModels.list(id = model_id_2)[0]
xf1 = m1.openState.xform
xf2 = m2.openState.xform
xf2.invert()
xf1.multiply(xf2)
print xf1

def register_accelerators():