[chimera-dev] Xform for rotation about a point
Thomas Goddard
goddard at cgl.ucsf.edu
Tue Jun 7 20:13:06 PDT 2005
> From: "Lavu Sridhar" <slavu at bcm.tmc.edu>
> To: "Thomas Goddard" <goddard at cgl.ucsf.edu>
> Subject: Rotation about arbitrary point
> Date: Tue, 7 Jun 2005 16:44:35 -0500
>
> Hi, Tom,
>
> I want to rotate a chimera model about
> an arbitrary point - (ax,ay,az).
>
> Basicallly, what I am looking for is
> something like following:
>
> xform.rotate(axis, angle, about_point)
>
> Is that possible?
>
> Thank you.
>
> Lavu
Hi Lavu,
There is not an Xform constructor to rotate about a specified point
although it would be nice and I'll suggest it to Greg Couch
(gregc at cgl.ucsf.edu) who maintains the Xform code.
Here is how you currently would create a rotation about a center (cx,cy,cz):
>>> center = chimera.Vector(cx, cy, cz)
>>> axis = chimera.Vector(ax, ay, az)
>>> angle = 123.4 # in degrees
>>> xf = chimera.Xform_translation(center)
>>> xf.rotate(axis, angle)
>>> xf.translate(-center)
# To apply transform to point p to get rp use:
>>> p = chimera.Point(px, py, pz)
>>> rp = xf.apply(p)
This transform acts on a point by first translating by (-cx,-cy,-cz) then
rotating about axis (ax,ay,az) by angle, then translating back by (cx,cy,cz).
That achieves the rotation you want about (cx,cy,cz). I'd suggest making
a function to do this if you need it at several places in your code.
Tom
More information about the Chimera-dev
mailing list