From: John Stone (johns_at_ks.uiuc.edu)
Date: Thu Jun 18 2009 - 15:39:12 CDT

Thomas,
  You can create a matrix containing your translation, then a matrix
with the rotation, concatenate them by multiplying them together
(see the various VMD matrix commands for this), and do a single
$sel move call.

Cheers,
  John Stone
  vmd_at_ks.uiuc.edu

On Thu, Jun 18, 2009 at 11:36:13PM +0300, Thomas Evangelidis wrote:
> sorry for the typo...
>
> set Sel [atomselect top all]
> $Sel moveby [list $X0 $Y0 $Z0]
> lappend M [list $a1 $b1 $c1]
> lappend M [list $a2 $b2 $c2]
> lappend M [list $a3 $b3 $c3]
> set M [trans_from_rotate $M]
> $Sel move $M
>
>
> >Thanks buddy. That should work but I can find faster ways around,
> >like doing the translation to the geometric center and then the
> >rotation (which is actually what I do now):
> >
> >set Sel [atomselect top all]
> >$Sel moveby [list $X0 $Y0 $Z0]
> >lappend qM [list $a1 $b1 $c1]
> >lappend qM [list $a2 $b2 $c2]
> >lappend qM [list $a3 $b3 $c3]
> >set M [trans_from_rotate $M]
> >$Sel move $M
> >
> >I'm just curious to know how to do it with a 4x4 matrix directly.
> >
> >Tom
> >
> >>You could map the coordinates using the "set" command. You would
> >>need to, e.g., load the molecule twice, changing the coordinates of
> >>one based on the other. It would approximately work like this:
> >>
> >>set sel [atomselect 0 all]
> >>
> >>foreach ind [$sel get index] {
> >> set temp1 [atomselect 0 "index $ind"]
> >> set temp2 [atomselect 1 "index $ind"]
> >> $temp2 set x [expr -0.79814*([$temp1 get x]-99.4985) +
> >>-0.50649*([$temp1 get y]-55.308) + 0.32625*([$temp1 get z]-26.91025)]
> >> $temp2 set y [expr ....]
> >> $temp2 set z [expr ....]
> >> $temp1 delete
> >> $temp2 delete
> >>}
> >>
> >>You could also do the mapping in place (only loading one structure)
> >>by using intermediate variables for the new coordinates before
> >>setting them.
> >>
> >>The 4x4 transformation matrix you are using is composed of a 3x3
> >>rotation matrix and a translation vector (with the last row being
> >>as you have given it), so it might take some work to determine it
> >>for the transformation you want.
> >>
> >>
> >>On Jun 18, 2009, at 2:55 AM, Thomas Evangelidis wrote:
> >>
> >>>Dear VMD users,
> >>>
> >>>I have the new coordinates of a protein in the following form:
> >>>
> >>> X2 = -0.79814*(X1-99.4985) + -0.50649*(Y1-55.308) +
> >>>-0.32625*(Z1-26.91025)
> >>> Y2 = 0.40972*(X1-99.4985) + -0.85333*(Y1-55.308) +
> >>>0.32243*(Z1-26.91025)
> >>> Z2 = -0.44171*(X1-99.4985) + 0.12367*(Y1-55.308) +
> >>>0.88859*(Z1-26.91025)
> >>>
> >>>So I set the following matrix for the transformation:
> >>>
> >>>{{-0.79814 -0.50649 -0.32625 -99.4985} {0.40972 -0.85333 0.32243
> >>>-55.308} {-0.44171 0.12367 0.88859 -26.91025} {0.0 0.0 0.0 1.0}}
> >>>
> >>>but the molecule is moved to a completely different location than
> >>>the one it should be. I am confused, either the matrix or the
> >>>coordinates are wrong. Can anyone shed some light on this please?
> >>>
> >>>thanks in advance,
> >>>Tom
> >>
> >>
> >
> >
> >----- End message from gumbart_at_ks.uiuc.edu -----
> >
> >
> >
>
>
> ----- End message from te8624_at_mbg.duth.gr -----
>
>

-- 
NIH Resource for Macromolecular Modeling and Bioinformatics
Beckman Institute for Advanced Science and Technology
University of Illinois, 405 N. Mathews Ave, Urbana, IL 61801
Email: johns_at_ks.uiuc.edu                 Phone: 217-244-3349
  WWW: http://www.ks.uiuc.edu/~johns/      Fax: 217-244-6078