[Chimera-users] orientation matrix
Eric Pettersen
pett at cgl.ucsf.edu
Thu Nov 18 14:16:26 PST 2004
I've implemented matrixget and matrixset now. It will be in the
snapshot we're putting out at the beginning of December. I can provide
the changed Python files to anyone who wants the matrix commands
earlier. I should note that there was an error in my earlier mail
(below) -- the function is chimera.Xform_xform(), not chimera.Xform().
Eric Pettersen
UCSF Computer Graphics Lab
pett at cgl.ucsf.edu
http://www.cgl.ucsf.edu
On Nov 1, 2004, at 12:04 PM, Eric Pettersen wrote:
>
> On Oct 31, 2004, at 7:28 AM, Miguel Ortiz Lombardía wrote:
>
>> Hi all,
>>
>> Sorry, this question may be very simple, but I didn't manage to find
>> an answer in the documentation.
>>
>> Is it possible to read a transformation (rotation + translation)
>> matrix so that the molecule is displayed exactly in the orientation
>> you wish?
>
> This is discussed a little in the programmer's FAQ, question #4
> (http://www.cgl.ucsf.edu/chimera/docs/ProgrammersGuide/faq.html). But
> that question doesn't talk about how to use an _arbitrary_
> rotation/translation matrix to set a model's transformation.
> Nonetheless, you should look at it to get the general idea of how to
> set a model's transformation matrix. At the end of this mail I've
> appended the definition of the Xform class, as our Python-wrapping
> program sees it (therefore, functions that are commented out [with
> '//'] are in the C++ code put not the Python layer). The routine you
> want is the constructor 'xform' that takes 12 numeric arguments
> defining the transformation matrix and an 'orthogonalize' boolean. So
> you would generate your transform with:
>
> xf = chimera.Xform(..12 numbers..., orthogonalize=True)
>
> You want 'orthogonalize' to be True so that Chimera will correct for
> any roundoff in your numeric arguments and produce an orthonormal
> matrix that is suitable for use as a transformation matrix. You then
> use the same general procedures as in FAQ question 4 to set the model
> transform.
>
> Now, this would be much easier if the Midas matrixget/matrixset
> commands were implemented in Chimera. I will work on that and let you
> know when it's done. Until then, you will need to use the Xform
> constructor.
>
> Eric Pettersen
> UCSF Computer Graphics Lab
> pett at cgl.ucsf.edu
> http://www.cgl.ucsf.edu
>
> class Xform
> {
> // WRAP CLASS
> // DON'T CACHE
> public:
> Xform(); // same as identity
> // The following static routines are the constructors:
> static Xform xform(Real r00, Real r01, Real r02, Real t03,
> Real r10, Real r11, Real r12, Real t13,
> Real r20, Real r21, Real r22, Real t23,
> bool orthogonalize = false);
> static Xform coordFrame(const Vector &x, const Vector &y,
> const Vector &z, const Point &origin,
> bool orthogonalize = false);
> static Xform identity();
> static Xform translation(Real x, Real y, Real z);
> static Xform translation(const Vector &v);
> static Xform xRotation(Real angle);
> static Xform yRotation(Real angle);
> static Xform zRotation(Real angle);
> static Xform rotation(Real x, Real y, Real z, Real angle);
> static Xform rotation(const Vector &axis, Real angle);
> //static Xform rotation(const Real mat[3][3], bool
> orthogonalize = fals
> e);
> static Xform zAlign(const Point &p0, const Point &p1);
> static Xform zAlign(const Point &p0, const Vector &v);
> static Xform lookAt(const Point &eye, const Point &at,
> const Point &u
> p);
> static Xform lookAt(const Point &eye, const Point &at,
> const Vector &
> up);
> void invert();
> void translate(Real x, Real y, Real z);
> void translate(const Vector &xyz);
> void xRotate(Real angle);
> void yRotate(Real angle);
> void zRotate(Real angle);
> void rotate(Real x, Real y, Real z, Real angle);
> void rotate(const Vector &xyz, Real angle);
> Point apply(const Point &pt) const;
> Vector apply(const Vector &vec) const;
> void premultiply(const Xform &xf);
> void multiply(const Xform &xf);
> bool isIdentity() const;
> void getRotation(/*OUT*/ Vector *axis, /*OUT*/ Real
> *angle) c
> onst;
> void getCoordFrame(/*OUT*/ Vector *x = NULL,
> /*OUT*/ Vector *y = NULL, /*OUT*/ Vector *z =
> NULL,
> /*OUT*/ Point *origin = NULL) const;
> void getTranslation(/*OUT*/ Vector *trans) const;
> //void get4by4(/*OUT*/ Real mat[4][4]) const;
> };
>
>
More information about the Chimera-users
mailing list