**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: [A_{x}, A_{y}, A_{z}]: a point in model space [B_{x}, B_{y}, B_{z}]: model rotation center [M_{11}, ..., M_{33}]: the rotation matrix [C_{x}, C_{y}, C_{z}]: same point in camera space [D_{x}, D_{y}, D_{z}]: camera rotation center We have the following mapping relation: |C_{x}-D_{x}| |M_{11}M_{12}M_{13}| |A_{x}-B_{x}| |C_{y}-D_{x}| = |M_{21}M_{22}M_{23}| * |A_{y}-B_{y}| |C_{z}-D_{x}| |M_{31}M_{32}M_{33}| |A_{z}-B_{z}|

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)