Model-to-Camera Space Coordinates Mapping

This section provides a tutorial on how to map model space coordinates to camera space coodinates manually using rotation center and rotation matrix in PyMol.

In previouse tutorials, we have learned how to use "turn" and "move", to change camera viewing angle and position, which impacts how the molecule structure is mapped from the model space to the camera space.

Here is the mapping formula use by PyMol:

```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|
```

Now let's verify this mapping formula by looking the methane molecule.

1. Load the methane molecule structure to PyMol again. You see the structure displayed at the center of the screen, which is perpandicular to the z-axis of the camera space.

```PyMOL>delete all
```

2. Get the view mapping parameters, which include the rotation matrix and the rotation center.

```PyMOL>get_view
### cut below here and paste into script ###
set_view (\
1.000000000,    0.000000000,    0.000000000,\ # M: rotation matrix
0.000000000,    1.000000000,    0.000000000,\ # M: rotation matrix
0.000000000,    0.000000000,    1.000000000,\ # M: rotation matrix
0.000000000,    0.000000000,  -14.178204536,\ # D: camera totation center
0.840320110,   -1.029980063,   -0.000119984,\ # B: model rotation center
11.178204536,   17.178203583,  -20.000000000 )
### cut above here and paste into script ###
```

3. Get coordinates of the carbon atom in the model space.

```PyMOL>select carbon, id 5
Selector: selection "carbon" defined with 1 atoms.
PyMOL>get_extent carbon
cmd.extent: min: [   0.840,  -1.030,   0.000]
cmd.extent: max: [   0.840,  -1.030,   0.000]
```

4. Run the formula on the carbon atom location. We get [0.000, 0.000, 0.000] in camera space. So the carbon atom should be displayed at the center of the screen.

```  |  0.000|   |1.000 0.000 0.000|   | 0.840 -  0.840|   |  0.000|
|  0.000| = |0.000 1.000 0.000| * |-1.030 - -1.030| + |  0.000|
|-14.178|   |0.000 0.000 1.000|   | 0.000 -  0.000|   |-14.178|
```

5. Repeat the calculation on hydrogen atom #4. We get [-0.108, -0.947, 0.529] in camera space.

```PyMOL>select h4, id 4
Selector: selection "h4" defined with 1 atoms.
PyMOL>get_extent h4
cmd.extent: min: [   0.732,  -1.977,   0.529]
cmd.extent: max: [   0.732,  -1.977,   0.529]

| -0.108|   |1.000 0.000 0.000|   | 0.732 -  0.840|   |  0.000|
| -0.947| = |0.000 1.000 0.000| * |-1.977 - -1.030| + |  0.000|
|-13.649|   |0.000 0.000 1.000|   | 0.529 -  0.000|   |-14.178|
```

You can continue on other hydrogen atoms.

The picture below shows coordinates of the carbon atom and hydrogen atom #4: