From: <ha...@st...> - 2004-09-28 21:31:47
|
OK, I was playing with this, and I think it's really easy. You have the transformation matrix, right, and it can be normalized to unit length (no zoom)? If I have this right, you pretty much just go down the line with the transformation matrix and "read" off the x, y, and z angles: define 3x3 (no-zoom) T: [ a11 a12 a13 a21 b22 b23 c31 c32 c33 ] Define R_z*R_y*R_x = T (rotate cw first x, then y, then z) where R_x = [ 1 0 0 0 cos(rx) sin(rx) 0 -sin(rx) cos(rx) ] and similarly for R_y and R_z then: R_y = arcSin(-c31) and if(c31==1 || c31==-1){ R_x = arcCos(c12) R_Z = PI/2 }else{ R_x = arcCos(c33/cos(R_y)) R_z = arcCos(c11/cos(R_y)) } I believe that does it! I tested this out on a spreadsheet, and it generated the original angles and correct transformation matrices every time. But I could be wrong. Note that there is an ambiguity for a +/-90 degree rotation about y. In that case there are many equivalent R_x/R_z combinations. It serves simply to define R_z=90 and go from there. I think it works. Bob > Miguel wrote: > >>Jan wrote: >> >> >>>I didn't intend to vote for an alteration of show center, my intention >>>was that >>>show rotation should be a synonym for show axisangle because it was the >>>same (if no bond was selected) but the output >>> show rotation >>>rotate x 30 >>>rotate y 10 >>>rotate z 20 >>>I didn't vote for conservation of the output, although it was very nice, >>>you could copy and past it in your script and would get just this >>>orientation, but rotation should be aliased to axisangle >>> >>> >> >>Now I am somewhat confused :-) >> >>It looks like to me that the OpenRasMol 'show rotation' command outputs >>stuff as degrees in X, Y, and Z. >> >>Given a transformation matrix, I do not know how to calculate the >>individual x, y, and z rotations that when applied (in that order) will >>generate the same transformation matrix. >> >>Q: Bob and/or Olaf, can you help with this? >> >> >> >> >>>>Q: What does this do? >>>> >>>> >>>> >>>> >>>the same as >>> show axisangle >>>(if no bond is selected with >>> bond src dest pick >>>) >>> >>> >>> >>>>>show translation >>>>> >>>>> >>>>> >>>>I assume this shows X and Y percentages of translation. >>>> >>>>Q: Are these numbers integers? >>>> >>>> >>>> >>>that is true, but this should be extended to Angstoem like the other >>>commands when using float values. >>> >>> >> >>True. >>Currently this is difficult to implement because translations are still >>being done in pixel values, not in angstrom coordinate space. >> >> >> >>>>>show zoom >>>>> >>>>> >>>>> >>>>> >>>>I assume this shows a zoom percentage value. >>>> >>>>Q: Is the output an integer? >>>> >>>> >>>> >>>> >>>yes if you use >>> zoom 300 >>> show zoom >>>would report >>>zoom 300 >>> >>>(again, ready for copy and past) >>> >>> >> >>Yes, I now understand that the output of the 'show' commands should be >>read for copy/paste. >> >>Q: If there is more than one way to generate something, how should the >>output of 'show' be generated? >> >>For example 'show rotation' could show: >> >> moveto .234 .987 .785 49 >>OR >> reset; rotate axisangle .234 .987 .785 49 >>OR >> reset; rotate x 10; rotate y 20; rotate z 30 >> >> > and translation. > I would vote for this, because this is the easiest to imagine, despite > it is not the most secure to reproduce. > Regards, Jan > >>How should we output this stuff os that it is easy to identify that there >>are various options for achieving the same result? >> >> >>Miguel >> >> > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users > |
From: Bob H. <ha...@st...> - 2004-09-30 12:33:00
|
[this is not really something for the Jmol-users list, but since it started that way, I feel I should continue] OK, not QUITE that easy. What I showed initially works only for -90<angle<90. The following is a general solution (I believe): Define pure rotation 3x3 tansform: T= R_x*R_y*R_z such that ActualCoord * T = 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 ] (This is what CAChe uses; I presume same for jmol, but don't know.) then with T: [ a11 a12 a13 a21 a22 a23 a31 a32 a33 ] we have: Ry=asin(a13) if(a13==-1||a13==1){ Rx=arcTan(a32,a22) Rz=0 }else{ Rx=arcTan(-a23,a33) Rz=arcTan(-a12,a11) } if(Rx>PI)Rx-=2*PI if(Ry>PI)Ry-=2*PI if(Rz>PI)Rz-=2*PI This presumes the arcTan(y,x) function: function arcTan(y,x){ return(x!=0?atan(y/x)+(x<0?PI:0):y<0?-PI/2:PI/2) } Note that this function recognizes when x<0, implying the angle should be in the range [PI/2,3PI/2] Spreadsheet random input validation is at http://www.stolaf.edu/people/hansonr/jmol/test/transform.xls > >>Miguel wrote: >> >>> >>>Given a transformation matrix, I do not know how to calculate the >>>individual x, y, and z rotations that when applied (in that order) will >>>generate the same transformation matrix. >>> >>>Q: Bob and/or Olaf, can you help with this? -- 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 |
From: Bob H. <ha...@st...> - 2004-10-04 03:51:59
|
[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 |
From: Bob H. <ha...@st...> - 2004-09-28 18:15:12
|
Olaf is hospitalized today. What you want is: given T, what are Rx, Ry, and Rz such that Rx * Ry * Rz = T Right? I'll have to think about that. I'm not sure there's a unique solution. But I'd like to have one if there is. Don't hold your breath. Bob Old Address wrote: > Miguel wrote: > >> Jan wrote: >> >> >>> I didn't intend to vote for an alteration of show center, my intention >>> was that >>> show rotation should be a synonym for show axisangle because it was the >>> same (if no bond was selected) but the output >>> show rotation >>> rotate x 30 >>> rotate y 10 >>> rotate z 20 >>> I didn't vote for conservation of the output, although it was very nice, >>> you could copy and past it in your script and would get just this >>> orientation, but rotation should be aliased to axisangle >>> >> >> >> Now I am somewhat confused :-) >> >> It looks like to me that the OpenRasMol 'show rotation' command outputs >> stuff as degrees in X, Y, and Z. >> >> Given a transformation matrix, I do not know how to calculate the >> individual x, y, and z rotations that when applied (in that order) will >> generate the same transformation matrix. >> >> Q: Bob and/or Olaf, can you help with this? >> >> >> >> >>>> Q: What does this do? >>>> >>>> >>>> >>> >>> the same as >>> show axisangle >>> (if no bond is selected with >>> bond src dest pick >>> ) >>> >>> >>> >>>>> show translation >>>>> >>>>> >>>> >>>> I assume this shows X and Y percentages of translation. >>>> >>>> Q: Are these numbers integers? >>>> >>>> >>> >>> that is true, but this should be extended to Angstoem like the other >>> commands when using float values. >>> >> >> >> True. >> Currently this is difficult to implement because translations are still >> being done in pixel values, not in angstrom coordinate space. >> >> >> >>>>> show zoom >>>>> >>>>> >>>>> >>>> >>>> I assume this shows a zoom percentage value. >>>> >>>> Q: Is the output an integer? >>>> >>>> >>>> >>> >>> yes if you use >>> zoom 300 >>> show zoom >>> would report >>> zoom 300 >>> >>> (again, ready for copy and past) >>> >> >> >> Yes, I now understand that the output of the 'show' commands should be >> read for copy/paste. >> >> Q: If there is more than one way to generate something, how should the >> output of 'show' be generated? >> >> For example 'show rotation' could show: >> >> moveto .234 .987 .785 49 >> OR >> reset; rotate axisangle .234 .987 .785 49 >> OR >> reset; rotate x 10; rotate y 20; rotate z 30 >> >> > and translation. > I would vote for this, because this is the easiest to imagine, despite > it is not the most secure to reproduce. > Regards, Jan > >> How should we output this stuff os that it is easy to identify that there >> are various options for achieving the same result? >> >> >> Miguel >> >> > > > > ------------------------------------------------------- > This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 > Project Admins to receive an Apple iPod Mini FREE for your judgement on > who ports your project to Linux PPC the best. Sponsored by IBM. > Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php > _______________________________________________ > Jmol-users mailing list > Jmo...@li... > https://lists.sourceforge.net/lists/listinfo/jmol-users |
From: Miguel <mi...@jm...> - 2004-09-29 14:53:33
|
> Olaf is hospitalized today. What you want is: > > given T, > > what are Rx, Ry, and Rz such that > > Rx * Ry * Rz = T > > Right? Correct! I wish I could have said that :-) > I'll have to think about that. I'm not sure there's a unique solution. I am sure that there is not a unique solution. But any solution would be fine. > But I'd like to have one if there is. Don't hold your breath. :-) Miguel |