Jmol/Quaternions

From Proteopedia

(Difference between revisions)
Jump to: navigation, search
Line 86: Line 86:
For the second example script, I wanted to rotate the view back to the initial orientation. For small adjustments, I wanted it to take a small time, while for larger adjustment, I wanted to spend enough time that you can easily follow. The Jmol moveto command takes a duration for the entire rotation as a parameter. If I set this to a fixed value, it would be too slow for small adjustments or too fast for large rotations. So I had to figure out by how many degrees I would rotate first, and then decide on the timing accordingly.
For the second example script, I wanted to rotate the view back to the initial orientation. For small adjustments, I wanted it to take a small time, while for larger adjustment, I wanted to spend enough time that you can easily follow. The Jmol moveto command takes a duration for the entire rotation as a parameter. If I set this to a fixed value, it would be too slow for small adjustments or too fast for large rotations. So I had to figure out by how many degrees I would rotate first, and then decide on the timing accordingly.
-
<jmol><jmolButton><script>q1 = quaternion()</script><text>store first orientation</text></jmolButton></jmol>
+
<jmol><jmolButton><script>q1 = quaternion(); set echo top left; echo "orientation stored"</script><text>store first orientation</text></jmolButton></jmol>
After pressing the button above, rotate the model a bit or a lot. Now will will go back the first orientation, with a nice speed no matter how different they are:
After pressing the button above, rotate the model a bit or a lot. Now will will go back the first orientation, with a nice speed no matter how different they are:
-
<jmol><jmolButton><script>q2 = quaternion(); rotation = q2 / q1; rotangle = rotation%"theta"; duration = rotangle/45 + 0.1; set echo top left; t = "rotate by " + (rotangle%3) + "degrees"; echo @t; moveto @duration quaternion @q1</script><text>back to first orientation</text></jmolButton></jmol>
+
<jmol><jmolButton><script>q2 = quaternion(); rotation = q2 / q1; rotangle = rotation%"theta"; duration = rotangle/45 + 0.1; set echo top left; t = "rotate by " + (rotangle%1) + " degrees"; echo @t; moveto @duration quaternion @q1</script><text>back to first orientation</text></jmolButton></jmol>

Revision as of 18:06, 25 July 2019

Drag the structure with the mouse to rotate

Resources

http://sacredsoftware.net/tutorials/quaternion.html

Proteopedia Page Contributors and Editors (what is this?)

Karsten Theis

Personal tools