[Chimera-users] Feature Request: Expose rotation to python
Charlie Moad
cwmoad at gmail.com
Tue Nov 29 07:01:49 PST 2005
Thanks for all this. It is working great!
Now comes the inverse question which should hopefully be easy. How
do I apply an xform to a structure to update the viewer? Applying
rotations to the model.openState.xform seems to have no effect. I
would like to be able to reset to the original view by doing something
like, model.openState.xform.multiply(model.openState.xform.inverse()).
Thanks,
Charlie
On 11/28/05, Greg Couch <gregc at cgl.ucsf.edu> wrote:
> On Mon, 28 Nov 2005, Charlie Moad wrote:
>
> > The repr of an xform shows the opengl rotation matrix. I want to
> > get this efficiently in python, but I don't believe it is exposed.
> > Could a getter please be added returning a 4x4 tuple, so a Numeric
> > array can be trivial/efficiently made from it? If there is a current
> > approach please let me know.
>
> The new and improved method is to use the getCoordFrame method :-) and
> the coorresponding Xform.coordFrame constructor. I agree that it would be
> better for Python to have a method that returned a Numeric array.
>
> Example:
>
> >>> xf = chimera.Xform.zRotation(30)
> >>> x, y, z, o = xf.getCoordFrame()
> >>> print "x: %s, y: %s, z: %s, o: %s" % (x, y, z, o)
> x: 0.866025 0.5 0, y: -0.5 0.866025 0, z: 0 0 1, o: 0 0 0
>
> Using getCoordFrame would simplify PDBmatrices.matrices.xform_matrix to
> be:
>
> rx, ry, rz, t = xform.getCoordFrame()
> return ((rx[0], ry[0], rz[0], t[0]),
> (rx[1], ry[1], rz[1], t[1]),
> (rx[2], ry[2], rz[2], t[2]))
>
> You could do something similar to construct a Numeric array.
>
> Xforms have improved in the latest release. Now you can easily make
> copies of matrices using the constructor:
>
> xformprime = chimera.Xform(xform)
>
> or:
>
> import copy
> xformprime = copy.copy(xform)
>
> Type:
>
> help(chimera.Xform)
>
> to see all of the methods and static methods.
>
> Hope this helps,
>
> Greg Couch
> UCSF Computer Graphics Lab
> gregc at cgl.ucsf.edu
>
>
More information about the Chimera-users
mailing list