Molecule Tutorials - Herong's Tutorial Examples - v1.21, by Dr. Herong Yang
Camera-to-Model Space Coordinates Mapping
This section provides a tutorial on how to map camera space coordinates to model space coodinates manually using the reverse of the rotation matrix in PyMol.
In the last tutorial, we have used the following mapping relation to map a point in model space to camera space, which is very easy.
Assuming: [Ax, Ay, Az]: a point in model space [Bx, By, Bz]: model rotation center [M11, ..., M33]: the rotation matrix [Cx, Cy, Cz]: same point in camera space [Dx, Dy, Dz]: camera rotation center We have the following mapping relation: |Cx-Dx| |M11 M12 M13| |Ax-Bx| |Cy-Dx| = |M21 M22 M23| * |Ay-By| |Cz-Dx| |M31 M32 M33| |Az-Bz|
But what about mapping a point in the camera space to the model space? It is also easy to do, if you know how to reverse the rotation matrix, using the "numpy" Python module.
1. Load the methane molecule structure to PyMol again. And convert viewing parameters into 'numpy' matrix and vectors:
PyMOL>delete all PyMOL>load Molecule-Methane.sdf CmdLoad: loaded as "Molecule-Methane". PyMOL>view = cmd.get_view() PyMOL>M1 = [view[i] for i in range(0,3)] PyMOL>M2 = [view[i] for i in range(3,6)] PyMOL>M3 = [view[i] for i in range(6,9)] PyMOL>M = numpy.matrix([M1, M2, M3]) PyMOL>D = numpy.matrix([[view[9]],[view[10]],[view[11]]]) PyMOL>B = numpy.matrix([[view[12]],[view[13]],[view[14]]])
2. Get the reverse of the rotation matrix and call it R:
PyMOL>R = M.I
3. We are ready to convert any point in the model space, A, to the camera space, C:
C = M*(A-B) + D A = R*(C-D) + B
You can verify this with some examples.
Table of Contents
Molecule Names and Identifications
Nucleobase, Nucleoside, Nucleotide, DNA and RNA
RDKit: Open-Source Cheminformatics Software
Load Molecule from File into PyMol
Virtual Trackball Rotation on PyMol
"load" and "delete" Commands on PyMol
"log_open" and "log_close" Commands on PyMol
Model Space and Camera Space on PyMol
"get_view" and "set_view" on PyMol
View Parameters Auto Adjusted on PyMol
Rotation with Transformation Matrix
Difference of "turn" and "rotate" Commands
Difference of "move" and "translate" Commands
"center", "zoom" and "reset" Commands
Model-to-Camera Space Coordinates Mapping
►Camera-to-Model Space Coordinates Mapping
"show lines" Presentation Command
"show sticks" Presentation Command
"show spheres" Presentation Command
"show surface" Presentation Command
"show mesh" Presentation Command
ChEMBL Database - European Molecular Biology Laboratory
PubChem Database - National Library of Medicine
INSDC (International Nucleotide Sequence Database Collaboration)