|
From: Bob H. <ha...@st...> - 2007-06-15 04:58:57
|
This is better -- it uses improper angles to set the sign of the angle
correctly.
Bob Hanson wrote:
>no simple way. HOWEVER, you could do the calculation I think. Let's see
>if it can be done with a Jmol script...
>
>Let's say we want to align the axis between atom 1 and atom 2 along the
>Z axis.
>
> Y
> |
> +--X
> /
> Z
>
>Strategy: rotate the axis around the Z axis into the XZ plane, then
>rotate it around the Y axis into the YZ plane.
>To do this, we need two angles:
>
>a) the angle of the axis projected into the XY plane and the X axis,
>and, after that,
>b) the angle between the axis and the Z axis.
>
>try this:
>
>
>
#atoms to align:
a1 = 1
a2 = 2
# just for testing:
select *;color cpk;
select atomno=a1;color yellow;spacefill 0.40;
select atomno=a2;color green;spacefill 0.25
select atomno=a1 or atomno=a2; label on
set axesmolecular
axes on
# align molecular and window frame coordinate system;
reset
select *
# move atom 1 to {0 0 0}:
x = -{atomno=a1}.x
y = -{atomno=a1}.y
z = -{atomno=a1}.z
translateSelected {@x @y @z}
# into the XZ plane, using an improper angle:
axisAB = {atomno=a2}.xyz - {atomno=a1}.xyz
x = axisAB.x
y = axisAB.y
#echo %{x} %{y}
projAB = {@x, @y, 0}
angleA = angle(projAB, {0 0 0}, {0 0 1}, {1 0 0})
#echo %{angleA}
rotateSelected Z @angleA
# move atom 1 to {0 0 0}:
x = -{atomno=a1}.x
y = -{atomno=a1}.y
z = -{atomno=a1}.z
translateSelected {@x @y @z}
# onto the Z axis, using an improper angle:
axisAB = {atomno=a2}.xyz - {atomno=a1}.xyz
x = axisAB.x
z = axisAB.z
#echo %{x} %{z}
projAB = {@x, 0, @z}
angleA = angle(projAB, {0 0 0}, {0 1 0}, {0 0 1})
#echo %{angleA}
rotateSelected Y @angleA
# move atom 1 to {0 0 0}:
x = -{atomno=a1}.x
y = -{atomno=a1}.y
z = -{atomno=a1}.z
translateSelected {@x @y @z}
Bob
|