Re: [Jmol-users] Orient molecule along bond or arbitrary axis
Dean, There are two coordinate systems -- that of the molecule and that of the reference frame. Is what you are asking to do to align some axis in the molecular system with some axis in the reference plane? In other words, something like "orient the axis going through atoms 1 and 2 along the X (horizontal) axis"? Bob Hanson Dean Johnston wrote: >Jmol users, > > Does anybody know a simple way to align a molecule in the Jmol viewer >along a bond or (arbitrary) axis? This axis may not correspond to one of >the original x, y, or z axes. (or front, back, top, etc.) I know you can >ROTATE around an arbitrary axis. I also know you can also NAVIGATE along a >PATH, but I just want to re-orient, not move anywhere. Am I overlooking >some obvious parameter to MOVETO? Thanks for any tips. > >Dean > > > >- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >___ >Jmol-users mailing list >Jmol-users@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/jmol-users > > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Orient molecule along bond or arbitrary axis
Exactly. I want to be able to "look down" a particular molecular axis - so I guess that might be "orient this bond along the Z axis". Dean On 6/14/07 10:45 PM, "Bob Hanson" <[EMAIL PROTECTED]> wrote: > Dean, > > There are two coordinate systems -- that of the molecule and that of the > reference frame. Is what you are asking to do to align some axis in the > molecular system with some axis in the reference plane? In other words, > something like "orient the axis going through atoms 1 and 2 along the X > (horizontal) axis"? > > > Bob Hanson > > > Dean Johnston wrote: > >> Jmol users, >> >> Does anybody know a simple way to align a molecule in the Jmol viewer >> along a bond or (arbitrary) axis? This axis may not correspond to one of >> the original x, y, or z axes. (or front, back, top, etc.) I know you can >> ROTATE around an arbitrary axis. I also know you can also NAVIGATE along a >> PATH, but I just want to re-orient, not move anywhere. Am I overlooking >> some obvious parameter to MOVETO? Thanks for any tips. >> >> Dean .. - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Orient molecule along bond or arbitrary axis
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 Z 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 along the Z axis: a1 = 1 a2 = 5 # 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 [EMAIL PROTECTED] @y @z} # into the XZ plane: axisAB = {atomno=a2}.xyz - {atomno=a1}.xyz x = axisAB.x y = axisAB.y #echo %{x} %{y} projAB = [EMAIL PROTECTED], @y, 0} angleA = angle(projAB, {0 0 0}, {1 0 0}) if (y > 0) angleA = -angleA endif #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 [EMAIL PROTECTED] @y @z} # onto the Z axis: axisAB = {atomno=a2}.xyz - {atomno=a1}.xyz x = axisAB.x z = axisAB.z #echo %{x} %{z} projAB = [EMAIL PROTECTED], 0, @z} angleA = -angle(projAB, {0 0 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 [EMAIL PROTECTED] @y @z} This works for me, but this sort of thing is tricky; I may have not accounted for all possibilities. In any case, you get the idea from this of what is possible now with arithmetic expressions. Certainly you can do what you want to do. Nice application of rotateSelected and translateSelected, I think. Bob Dean Johnston wrote: >Exactly. I want to be able to "look down" a particular molecular axis - so >I guess that might be "orient this bond along the Z axis". > >Dean > > >On 6/14/07 10:45 PM, "Bob Hanson" <[EMAIL PROTECTED]> wrote: > > > >>Dean, >> >>There are two coordinate systems -- that of the molecule and that of the >>reference frame. Is what you are asking to do to align some axis in the >>molecular system with some axis in the reference plane? In other words, >>something like "orient the axis going through atoms 1 and 2 along the X >>(horizontal) axis"? >> >> >>Bob Hanson >> >> >>Dean Johnston wrote: >> >> >> >>>Jmol users, >>> >>> Does anybody know a simple way to align a molecule in the Jmol viewer >>>along a bond or (arbitrary) axis? This axis may not correspond to one of >>>the original x, y, or z axes. (or front, back, top, etc.) I know you can >>>ROTATE around an arbitrary axis. I also know you can also NAVIGATE along a >>>PATH, but I just want to re-orient, not move anywhere. Am I overlooking >>>some obvious parameter to MOVETO? Thanks for any tips. >>> >>>Dean >>> >>> >.. > > > >- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >___ >Jmol-users mailing list >Jmol-users@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/jmol-users > > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Orient molecule along bond or arbitrary axis
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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], @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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], 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 [EMAIL PROTECTED] @y @z} Bob - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Orient molecule along bond or arbitrary axis
OK, not simple, but very impressive what you can do with the "molecular math". (I especially like the use of improper angles.) Now, if I want to orient along an line (as opposed to along a bond), can I do it the same way? Is there a way to extract the endpoints of a line? When I tried something like x = @line1.x I get what appears to be the center point of the line instead of either end. I guess I can always pass the information to Jmol using Javascript, since that's how I created the line in the first place. Dean On 6/15/07 12:58 AM, "Bob Hanson" <[EMAIL PROTECTED]> wrote: > 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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], @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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], 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 [EMAIL PROTECTED] @y @z} > > > > Bob > > > - > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > ___ > Jmol-users mailing list > Jmol-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jmol-users - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users
Re: [Jmol-users] Orient molecule along bond or arbitrary axis
draw objects just have centers in this context. but you could define the points: draw pt1 {0.0 3.1 1.3} off draw pt2 {0.1 2.1 1.0} off draw line1 @pt1 @pt2 and then use the points themselves, not the line, for your reference points. Be sure to use $ in front of the point id: x = -$pt1.x y = -$pt1.y z = -$pt1.z translateSelected [EMAIL PROTECTED] @y @z} Otherwise Jmol will be looking for a variable named "pt1" not an object named "pt1" Bob Dean Johnston wrote: >OK, not simple, but very impressive what you can do with the "molecular >math". (I especially like the use of improper angles.) > >Now, if I want to orient along an line (as opposed to along a bond), can I >do it the same way? Is there a way to extract the endpoints of a line? >When I tried something like x = @line1.x I get what appears to be the center >point of the line instead of either end. I guess I can always pass the >information to Jmol using Javascript, since that's how I created the line in >the first place. > > > >Dean > > >On 6/15/07 12:58 AM, "Bob Hanson" <[EMAIL PROTECTED]> wrote: > > > >>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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], @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 [EMAIL PROTECTED] @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 = [EMAIL PROTECTED], 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 [EMAIL PROTECTED] @y @z} >> >> >> >>Bob >> >> >>- >>This SF.net email is sponsored by DB2 Express >>Download DB2 Express C - the FREE version of DB2 express and take >>control of your XML. No limits. Just data. Click to get it now. >>http://sourceforge.net/powerbar/db2/ >>___ >>Jmol-users mailing list >>Jmol-users@lists.sourceforge.net >>https://lists.sourceforge.net/lists/listinfo/jmol-users >> >> > > > >- >This SF.net email is sponsored by DB2 Express >Download DB2 Express C - the FREE version of DB2 express and take >control of your XML. No limits. Just data. Click to get it now. >http://sourceforge.net/powerbar/db2/ >___ >Jmol-users mailing list >Jmol-users@lists.sourceforge.net >https://lists.sourceforge.net/lists/listinfo/jmol-users > > - This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ ___ Jmol-users mailing list Jmol-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jmol-users