Jmol/Quaternions

From Proteopedia

(Difference between revisions)
Jump to: navigation, search
Current revision (16:38, 21 June 2020) (edit) (undo)
m (User:Karsten Theis/quaternions moved to Jmol/Quaternions: add to other Jmol resources, let others edit)
 
(8 intermediate revisions not shown.)
Line 1: Line 1:
-
<StructureSection load='' size='340' side='right' caption='' scene='43/433638/Fullview_cartoon/20'>
+
<StructureSection load='' size='340' side='right' caption='' scene='43/433638/Fullview_cartoon/21'>
==Examples of how quaterions are used==
==Examples of how quaterions are used==
Line 23: Line 23:
Jmol shows structures (e.g. atomic positions) on a display and allows the view to be rotated and individual atomic positions to be manipulated. The display has Cartesion coordinates (the x-axis goes right, the y-axis goes up, and the z-axis points at the viewer). The atoms have Cartesian coordinates x, y, z. The meaning of the axes is sometimes arbitrary (NMR structures) or along certain crystallographic directions (X-ray structures). When you rotate the model, the coordinate system of the model is rotated (same coordinates x, y, z, but axes of coordinate system point in different directions) with respect to the display coordinate system.
Jmol shows structures (e.g. atomic positions) on a display and allows the view to be rotated and individual atomic positions to be manipulated. The display has Cartesion coordinates (the x-axis goes right, the y-axis goes up, and the z-axis points at the viewer). The atoms have Cartesian coordinates x, y, z. The meaning of the axes is sometimes arbitrary (NMR structures) or along certain crystallographic directions (X-ray structures). When you rotate the model, the coordinate system of the model is rotated (same coordinates x, y, z, but axes of coordinate system point in different directions) with respect to the display coordinate system.
-
<jmol><jmolButton><script>axes on</script><text>show axes</text></jmolButton></jmol>
+
<jmol><jmolButton><script>axes MOLECULAR; axes on</script><text>show axes</text></jmolButton></jmol>
When a new structure is loaded, the model axes point left, up, and out of the screen. The Jmol command "reset" puts that coordinate system back into that initial orientation.
When a new structure is loaded, the model axes point left, up, and out of the screen. The Jmol command "reset" puts that coordinate system back into that initial orientation.
-
<jmol><jmolButton><script>reset</script><text>reset to initial orientation</text></jmolButton></jmol>
+
<jmol><jmolButton><script>reset; axes MOLECULAR; axes on</script><text>reset to initial orientation</text></jmolButton></jmol>
==Changing orientations using quaternions==
==Changing orientations using quaternions==
Line 33: Line 33:
The Jmol command "q = quaternion()" assigns the current orientation to q.
The Jmol command "q = quaternion()" assigns the current orientation to q.
-
<jmol><jmolButton><script>q = quaternion()</script><text>save orientation</text></jmolButton></jmol>
+
<jmol><jmolButton><script>q = quaternion()</script><text>store orientation</text></jmolButton></jmol>
So, again, how is an orientation different from a rotation? An orientation is the rotation necessary to get the coordinate system from the "reset" orientation to the current orientation. The quaternion ''q0'' for the initial orientation corresponds to no rotation, i.e. {0 0 1 0}. To get back to an orientation ''q'' after rotating, use "moveto 0 quaternion q". After you saved an orientation, click the reset button above and then go back to the saved orientation with the button below.
So, again, how is an orientation different from a rotation? An orientation is the rotation necessary to get the coordinate system from the "reset" orientation to the current orientation. The quaternion ''q0'' for the initial orientation corresponds to no rotation, i.e. {0 0 1 0}. To get back to an orientation ''q'' after rotating, use "moveto 0 quaternion q". After you saved an orientation, click the reset button above and then go back to the saved orientation with the button below.
-
<jmol><jmolButton><script>moveto 0 quaternion @q</script><text>go to saved orientation</text></jmolButton></jmol>
+
<jmol><jmolButton><script>moveto 0 quaternion @q</script><text>go to stored orientation instantly</text></jmolButton></jmol>
 +
 
 +
<jmol><jmolButton><script>moveto 2 quaternion @q</script><text>go to stored orientation gradually</text></jmolButton></jmol>
Relevant Jmol command examples:
Relevant Jmol command examples:
q = quaternion() # store current orientation
q = quaternion() # store current orientation
moveto 0 quaternion @q # go back to stored orientation instantly
moveto 0 quaternion @q # go back to stored orientation instantly
-
moveto 1 quaternion @q # go back to stored orientation gradually
+
moveto 2 quaternion @q # go back to stored orientation gradually (2 sec)
==Combining two rotations==
==Combining two rotations==
Line 55: Line 57:
Choosing x = 1, y = 0.5, z = 0 and tilt = 10, the buttons illustrate the commands.
Choosing x = 1, y = 0.5, z = 0 and tilt = 10, the buttons illustrate the commands.
 +
<jmol><jmolButton><script>s = quaternion(); r = quaternion({1 0.5 0},10); tilted = r * s; moveto 1 quaternion @tilted </script><text>tilt 10 degrees away from view</text></jmolButton></jmol>
<jmol><jmolButton><script>s = quaternion(); r = quaternion({1 0.5 0},10); tilted = r * s; moveto 1 quaternion @tilted </script><text>tilt 10 degrees away from view</text></jmolButton></jmol>
Line 78: Line 81:
<jmol><jmolButton><script>q10 = @qr / 10; rotate @q10</script><text>rotate one tenth</text></jmolButton></jmol>
<jmol><jmolButton><script>q10 = @qr / 10; rotate @q10</script><text>rotate one tenth</text></jmolButton></jmol>
-
<jmol><jmolButton><script>q10 = @qr / 10;
+
<jmol><jmolButton><script>q10 = @qr / 10;
-
qn = q10 * q0; moveto 0.2 quaternion @qn;
+
moveto 0 quaternion @q0;delay 0.5;
-
qn = (q10 * 3) * q0; moveto 0.2 quaternion @qn;
+
qn = q10 * q0; moveto 0.5 quaternion @qn;
 +
qn = (q10 * 3) * q0; moveto 0.3 quaternion @qn;
qn = (q10 * 7) * q0; moveto 0.2 quaternion @qn;
qn = (q10 * 7) * q0; moveto 0.2 quaternion @qn;
-
qn = (q10 * 9) * q0; moveto 0.2 quaternion @qn;
+
qn = (q10 * 9) * q0; moveto 0.3 quaternion @qn;
-
qn = (q10 * 10) * q0; moveto 0.2 quaternion @qn;
+
qn = (q10 * 10.1) * q0; moveto 0.5 quaternion @qn;
 +
qn = (q10 * 10) * q0; moveto 0.5 quaternion @qn;
</script><text>rotate all the way with variable speed</text></jmolButton></jmol>
</script><text>rotate all the way with variable speed</text></jmolButton></jmol>

Current revision

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