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:

where:

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

where:

You can verify this with some examples.