From: "Lavu Sridhar" slavu@bcm.tmc.edu To: "Thomas Goddard" goddard@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@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
participants (1)
-
Thomas Goddard