very cool -- I'm going to need to study that....   :)
-Tom

On Wed, Feb 3, 2010 at 12:05 PM, Robert Hanson <hans...@stolaf.edu> wrote:

> Takes some getting used to. Basically:
>
> 1) You can define little local xyz frames based on any three atoms.
> 2) You can use "differences" of quaternions -- q1/q2 -- to determine
> relative orientation.
> 3) You can use quaternions in rotation commands in Jmol.
>
> I think the best demo of this is http://chemapps.stolaf.edu/klotho/
>
> Here we have a database that has a wonderful selection of models. But when
> you scan through them, they (originally) are in odd orientations. I use
> quaternions on the chains to determine what their orientation is and then
> reset the orientation to that as they are delivered to the user.
>
> Works like a charm! Take a look at the source of that page. The script
> looks like this:
>
>  if(what.indexOf("pyranose") >= 0 || what.indexOf("furanose") >= 0 || 
> what.indexOf("osamine") >= 0) {
>
>       resetScript += '\
>       anomericC = {_C and connected(2, _O) and connected(4)};\
>       if (anomericC.size > 0);\
>               furanose = substructure(\\"[C]1[C][C][C][O]1\\")[1][5];\
>               pyranose = substructure(\\"[C]1[C][C][C][C][O]1\\")[1][6];\
>
>               anomericC = anomericC[1];\
>               ringO = within(\\"branch\\",anomericC,{_C and 
> connected(anomericC)}) and {_O} and {connected(anomericC)};\
>               if (ringO.size == 0);\
>                       ringO = within(\\"branch\\",anomericC,{_C and 
> connected(anomericC)}[2]) and {_O} and {connected(anomericC)};\
>
>               endif;\
>               anomericO = {_O} and connected(anomericC) and not ringO;\
>               ringC = within(\\"branch\\",anomericC,{ringO}) and {_C} and 
> {connected(anomericC)};\
>               rotate quaternion @{!quaternion(anomericC,ringC,ringO)};\
>
>               rotate y 180;rotate x -60;rotate y 20;rotate x 20;rotate y 30;\
>               if(furanose.size>0 and pyranose.size==0);\
>                       rotate z 20;\
>               endif;\
>               center {anomericC};\
>               set rotationradius 8;\
>
>
>       endif;\
>
>
>
> Cool, huh?
>
> :)
>
> Bob
>
>
>
> On Wed, Feb 3, 2010 at 12:58 PM, Thomas Stout <thomasjst...@gmail.com>wrote:
>
>> Thank you for that detailed explanation of quaternions, Bob!  This is the
>> first time I've actually been able to picture how to utilize them in a
>> general way..... (guess I just needed a different explanation)
>>
>> -Tom
>>
>>
>>
>> On Wed, Feb 3, 2010 at 7:09 AM, Robert Hanson <hans...@stolaf.edu> wrote:
>>
>>> Otis,
>>> 1) It works like a charm, at least with 2-butanol. I understand what
>>>
>>>> each line in your script is "saying," but I never could have come up
>>>> with this on my own!
>>>>
>>>>
>>> excellent!
>>>
>>>
>>>> 2) The find axis component of the script will be of general use to me.
>>>> I've been agonizing over drawing initial structures to align with the
>>>> molecular xyz axis to pre wire structures for Jmol animation scripts.
>>>> It seems that there is no need for this. I need to take a closer look
>>>> at the Jmol math features. I'm embarrassed to admit that I did not
>>>> know that the vector math in your script was a Jmol option.
>>>>
>>>>
>>> If you are having the need to orient structures, try looking into the
>>> quaternion function. It is VERY powerful. Say, for example, you want to
>>> orient a structure so that the atom 3 is at the origin, atom 1 is along x,
>>> and atom 2 is along y. It's as simple as this:
>>>
>>> q = quaternion({atomno=1}, {atomno=2}, {atomno=3})
>>>
>>> reset;rotate quaternion  @{!q}
>>>
>>> What we are doing here is to define a frame of reference as a quaternion
>>> (a set of four numbers). The frame is based on a center at atom 1, x axis in
>>> the direction from 1 to 2, and y axis in the plane 1-2-3. The quaternion
>>> describes the rotation necessary to take the default XYZ frame and rotate it
>>> to this frame. The @{!q} notation specifies that we want to rotate the model
>>> by the reverse of this rotation, thus setting the orientation to that
>>> particular frame.
>>>
>>> If you don't want to reset the zoom, you can reset the rotation only
>>> with:
>>>
>>> rotate quatenion @{ !quaternion(script("show rotation")) }
>>>
>>> Because the show rotation command returns a quaternion, and negating that
>>> gets you back to the original orientation, like reset, but without the
>>> centering or zoom.
>>>
>>> So, together that is:
>>>
>>> q = quaternion({atomno=1}, {atomno=2}, {atomno=3})
>>> q0 = quaternion(script("show rotation"))
>>>
>>> rotate quaternion @{(!q) / q0}
>>>
>>> Here
>>>
>>> a)  DIVIDE is the same as NOT
>>> b)  operation order is from right to left, like matrix multiplication.
>>> c) we need to group the !q in parentheses, because usually NOT is carried
>>> out after * and /, not before.
>>>
>>> This reads: "undo the orientation back to the standard view, then undo
>>> the atom-frame rotation.
>>>
>>>
>>> Probably more than you wanted to know.....
>>>
>>> Bob
>>>
>>>
>>>
>>>
>>>> 3) I've casually followed the user group for many years, but I only
>>>> recently started asking group questions related to the rebirth of an
>>>> old Jmol project. I don't know the protocol for requests or key words,
>>>> can you point me?
>>>>
>>>> Otis
>>>>
>>>> On Tue, Feb 2, 2010 at 12:38 PM, Robert Hanson <hans...@stolaf.edu>
>>>> wrote:
>>>> > Otis,
>>>> >
>>>> > It would be good to implement that. Feature request! Suggest a keyword
>>>> > option that would describe this.
>>>> >
>>>> > There is a scripting way to do this. You find the axis perpendicular
>>>> to the
>>>> > two groups, determine the angle required, and rotate one CW while the
>>>> other
>>>> > CCW.
>>>> >
>>>> > Given center {C} and two attached carbons, {Ca} and {Cb}, then:
>>>> >
>>>> > v1 = {Ca}.xyz - {C}.xyz
>>>> > v2 = {Cb}.xyz - {C}.xyz
>>>> > theAxis = cross(v1, v2)
>>>> > theAngle = angle(v1, {0 0 0}, v2)
>>>> >
>>>> > the two groups are found using select within(BRANCH,....)
>>>> > Then you do rotateSelected:
>>>> >
>>>> > select within(BRANCH, {C}, {Ca})
>>>> > rotateSelected MOLECULAR {C} @theAxis @theAngle
>>>> > select within(BRANCH, {C}, {Cb})
>>>> > rotateSelected MOLECULAR {C} @theAxis @{-theAngle}
>>>> >
>>>> > Should do the trick.
>>>> >
>>>> >
>>>> > Bob
>>>> > On Tue, Feb 2, 2010 at 10:36 AM, Otis Rothenberger <o...@chemagic.com
>>>> >
>>>> > wrote:
>>>> >>
>>>> >> Hello-
>>>> >>
>>>> >> I'm trying to invert the configuration of a single carbon atom. The
>>>> >> symmetry operation of invertSelected inverts the configuration of
>>>> >> target atom attached carbon atoms as well as the target. I tried
>>>> >> selecting only the four target atom attached carbon atoms and then
>>>> >> cleaning up with a minimize. Interesting visual, but again
>>>> neighboring
>>>> >> atom configuration is inverted after minimization.
>>>> >>
>>>> >> Three questions:
>>>> >>
>>>> >> 1) Am I missing another invertSelected possibility?
>>>> >> 2) Alternatively, is there a general scripting approach to simply
>>>> swap
>>>> >> two groups attached to the target atom?
>>>> >> 3) Is there an alternative scripting path to my objective?
>>>> >>
>>>> >> Otis
>>>> >>
>>>> >> --
>>>> >> Otis Rothenberger
>>>> >> http://chemagic.org
>>>> >>
>>>> >>
>>>> >>
>>>> ------------------------------------------------------------------------------
>>>> >> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> >> Stay online with enterprise data centers and the best network in the
>>>> >> business
>>>> >> Choose flexible plans and management services without long-term
>>>> contracts
>>>> >> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> >> http://p.sf.net/sfu/theplanet-com
>>>> >> _______________________________________________
>>>> >> Jmol-users mailing list
>>>> >> Jmol-users@lists.sourceforge.net
>>>> >> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>> >
>>>> >
>>>> >
>>>> > --
>>>> > Robert M. Hanson
>>>> > Professor of Chemistry
>>>> > St. Olaf College
>>>> > 1520 St. Olaf Ave.
>>>> > Northfield, MN 55057
>>>> > http://www.stolaf.edu/people/hansonr
>>>> > phone: 507-786-3107
>>>> >
>>>> >
>>>> > If nature does not answer first what we want,
>>>> > it is better to take what answer we get.
>>>> >
>>>> > -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>>> >
>>>> >
>>>> ------------------------------------------------------------------------------
>>>> > The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> > Stay online with enterprise data centers and the best network in the
>>>> > business
>>>> > Choose flexible plans and management services without long-term
>>>> contracts
>>>> > Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> > http://p.sf.net/sfu/theplanet-com
>>>> >
>>>> > _______________________________________________
>>>> > Jmol-users mailing list
>>>> > Jmol-users@lists.sourceforge.net
>>>> > https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>> >
>>>> >
>>>>
>>>>
>>>>
>>>> --
>>>> Otis Rothenberger
>>>> http://chemagic.org
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>>> Stay online with enterprise data centers and the best network in the
>>>> business
>>>> Choose flexible plans and management services without long-term
>>>> contracts
>>>> Personal 24x7 support from experience hosting pros just a phone call
>>>> away.
>>>> http://p.sf.net/sfu/theplanet-com
>>>> _______________________________________________
>>>> Jmol-users mailing list
>>>> Jmol-users@lists.sourceforge.net
>>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>>
>>>
>>>
>>>
>>> --
>>> Robert M. Hanson
>>> Professor of Chemistry
>>> St. Olaf College
>>> 1520 St. Olaf Ave.
>>> Northfield, MN 55057
>>> http://www.stolaf.edu/people/hansonr
>>> phone: 507-786-3107
>>>
>>>
>>> If nature does not answer first what we want,
>>> it is better to take what answer we get.
>>>
>>> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> The Planet: dedicated and managed hosting, cloud storage, colocation
>>> Stay online with enterprise data centers and the best network in the
>>> business
>>> Choose flexible plans and management services without long-term contracts
>>> Personal 24x7 support from experience hosting pros just a phone call
>>> away.
>>> http://p.sf.net/sfu/theplanet-com
>>> _______________________________________________
>>> Jmol-users mailing list
>>> Jmol-users@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>>
>>>
>>
>>
>> ------------------------------------------------------------------------------
>> The Planet: dedicated and managed hosting, cloud storage, colocation
>> Stay online with enterprise data centers and the best network in the
>> business
>> Choose flexible plans and management services without long-term contracts
>> Personal 24x7 support from experience hosting pros just a phone call away.
>> http://p.sf.net/sfu/theplanet-com
>> _______________________________________________
>> Jmol-users mailing list
>> Jmol-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jmol-users
>>
>>
>
>
> --
> Robert M. Hanson
> Professor of Chemistry
> St. Olaf College
> 1520 St. Olaf Ave.
> Northfield, MN 55057
> http://www.stolaf.edu/people/hansonr
> phone: 507-786-3107
>
>
> If nature does not answer first what we want,
> it is better to take what answer we get.
>
> -- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
>
>
> ------------------------------------------------------------------------------
> The Planet: dedicated and managed hosting, cloud storage, colocation
> Stay online with enterprise data centers and the best network in the
> business
> Choose flexible plans and management services without long-term contracts
> Personal 24x7 support from experience hosting pros just a phone call away.
> http://p.sf.net/sfu/theplanet-com
> _______________________________________________
> Jmol-users mailing list
> Jmol-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jmol-users
>
>
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Jmol-users mailing list
Jmol-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jmol-users

Reply via email to