|
From: Bob H. <ha...@st...> - 2004-10-04 03:51:58
|
[This is not really something for the Jmol-users list, but since it
started that way, I feel I should finish it there as well.]
Final analysis:
Jmol use of transformation matrix and production
of sequential "rotate x <Rx>; rotate y <Ry>; rotate z <Rz>"
from a transformation matrix.
For the record...
Define pure rotation 3x3 tansform:
T= R_z*R_y*R_x
such that
T * InputCoord = ViewCoord
(rotate cw first x, then y, then z)
where R_x =
[
1 0 0
0 cos(rx) -sin(rx)
0 sin(rx) cos(rx)
]
where R_y =
[
cos(ry) 0 sin(ry)
0 1 0
-sin(ry) 0 cos(ry)
]
where R_z =
[
cos(rz) -sin(rz) 0
sin(rz) cos(rz) 0
0 0 1
]
then with T:
[
m00 m01 m02
m10 m11 m12
m20 m21 m22
]
or in terms of sines (s) and cosines (c):
T=
[
cy*cz sx*sy*cz-cx*sz cx*sy*cz+sx*sz
cy*sz sx*sy*sz+cx*cz cx*sy*sz-sx*cz
-sy sx*cy cx*cy
]
Then we have:
Ry=-asin(m20)
if(m20==-1||m20==1){
Rx=-atan2(m12,m11)
Rz=0
}else{
Rx=atan2(m21,m22)
Rz=atan2(m10,m00)
}
This logic pushes all the rotation into Rx when Ry=+/-90.
(In that case, a rotation about x and a rotation about z amount to
a rotation about the same axis.)
Spreadsheet random input validation is at
http://www.stolaf.edu/people/hansonr/jmol/test/transform.xls
(requires add-in matrix.xla)
--
Robert M. Hanson, ha...@st..., 507-646-3107
Professor of Chemistry, St. Olaf College 1520 St. Olaf Ave., Northfield, MN 55057
mailto:ha...@st... http://www.stolaf.edu/people/hansonr
|