problems with xformCoord and coord

Dear All, I'm doing a script change the coordinates x,y,z for one molecule to move it using xformCoord coordinate system but my script doesn't work very well. My function looks like: atom.setCoord(a.coord()-0.1*(vector(x,y,z))) How can I write it in xformCoord? a.setCoord doesn't return to me xformCoord even if I write all the variables using xformCoord. In other words, I'm asking about the "translation" of the function atom.setCoord() in xformCoord coordinates. Thank You -- Elisabeth Ortega Carrasco Universitat Autónoma de Barcelona (Spain) eortega@klingon.uab.es

On Wed, 9 Sep 2009, Elisabeth Ortega wrote:
Dear All,
I'm doing a script change the coordinates x,y,z for one molecule to move it using xformCoord coordinate system but my script doesn't work very well. My function looks like:
atom.setCoord(a.coord()-0.1*(vector(x,y,z)))
How can I write it in xformCoord? a.setCoord doesn't return to me xformCoord even if I write all the variables using xformCoord.
In other words, I'm asking about the "translation" of the function atom.setCoord() in xformCoord coordinates.
Thank You
-- Elisabeth Ortega Carrasco Universitat Aut�noma de Barcelona (Spain) eortega@klingon.uab.es
Hi Elisabeth, Here's a small script to illustrate how to get a model's transformation matrix and how atom coordinates are transformed (assuming that there is only a Molecule open and that it has been moved relative to its starting position): m = chimera.openModels.list()[0] a = m.atoms[0] xf = m.openState.xform print a.xformCoord() print a.coord() c = xf.apply(a.coord()) print c The first and third lines of output are always the same -- i.e., a.xformCoord() is equivalent to xf.apply(a.coord()). The model's transformation matrix (xform) converts coordinates from the model's coordinate frame to the lab coordinate frame (x-axis is to the right, y-axis is up, z-axis is out of the screen). Atom coordinates are always kept in the molecule's coordinate frame. To move in a different coordinate frame, represented by the xf transformation matrix, do: c = xf.apply(a.coord()) + chimera.Vector(x, y, z) xfinv = xf.inverse() a.setCoord(xfinv.apply(c)) And if you wanted to add a setXformCoord method to Atom: def setXformCoord(self, coord): xfinv = self.molecule.openState.xform.inverse() self.setCoord(xfinv.apply(coord)) chimera.Atom.setXformCoord = setXformCoord And then you could call atom.setXformCoord(coord). It's not very efficient, because it inverts the transformation matrix every time, but it might do what you want. - Greg
participants (2)
-
Elisabeth Ortega
-
Greg Couch